ngx-scroll-lock
Version:
Angular module for Page Scroll locking
2 lines • 2.96 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-scroll-lock",["exports","@angular/core"],e):e((t=t||self)["ngx-scroll-lock"]={},t.ng.core)}(this,function(t,e){"use strict";var o=function(){return(o=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},n=function(){function t(){this.target="",this.lock=!1,this.listenerOptions={capture:!1,passive:!1}}return t.prototype.ngOnInit=function(){this.targetElement=this.target?document.querySelector(this.target):document.body,!this.targetElement&&e.isDevMode()&&console.error('`NgxScrollLockComponent` need to receive "target" as an element, but it received "'+(this.target||"body")+"\". Please check if the element is unique and it's available in your DOM."),this.lock&&this.targetElement&&this.disableLock(this.targetElement)},t.prototype.ngOnDestroy=function(){this.targetElement&&this.enableLock(this.targetElement)},t.prototype.ngOnChanges=function(t){t.target&&!t.target.firstChange&&t.target.previousValue!==t.target.currentValue&&(this.enableLock(this.targetElement),this.targetElement=this.target?document.querySelector(this.target):document.body,this.lock&&this.targetElement&&this.disableLock(this.targetElement)),t.lock&&!t.lock.firstChange&&t.lock.previousValue!==t.lock.currentValue&&this.targetElement&&(t.lock.currentValue?this.disableLock(this.targetElement):this.enableLock(this.targetElement))},t.prototype.disableLock=function(t){this.targetElement.classList.add("ngx-scroll-lock"),this.isTouchDevice()&&this.targetElement.addEventListener("touchmove",this.preventTouchMove,this.listenerOptions)},t.prototype.enableLock=function(t){this.targetElement.classList.remove("ngx-scroll-lock"),this.isTouchDevice()&&this.targetElement.removeEventListener("touchmove",this.preventTouchMove,this.listenerOptions)},t.prototype.isTouchDevice=function(){return!!window&&("ontouchstart"in window||navigator.maxTouchPoints)},t.prototype.preventTouchMove=function(t){var e=t||o({},window.event,{touches:[]});return!!(e.touches&&e.touches.length>=1)||(e.preventDefault&&e.preventDefault(),!1)},t.decorators=[{type:e.Component,args:[{selector:"ngx-scroll-lock",template:"\n <style>\n .ngx-scroll-lock {\n box-sizing: border-box !important;\n overflow: hidden !important;\n position: inherit !important;\n }\n </style>\n <ng-content></ng-content>\n ",encapsulation:e.ViewEncapsulation.None}]}],t.propDecorators={target:[{type:e.Input}],lock:[{type:e.Input}]},t}(),r=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[n],imports:[],exports:[n]}]}],t}();t.NgxScrollLockComponent=n,t.NgxScrollLockModule=r,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-scroll-lock.umd.min.js.map