text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-page-scroll-core",["exports","@angular/core"],t):t(e["ngx-page-scroll-core"]={},e.ng.core)}(this,function(e,s){"use strict";var c=function(){return(c=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},n=function(){function t(e){this.startScrollPosition=0,this.interruptListenersAttached=!1,this.timer=null,e.scrollViews&&0!==e.scrollViews.length?this.isInlineScrolling=!0:(e.scrollViews=[e.document.documentElement,e.document.body,e.document.body.parentNode],this.isInlineScrolling=!1),this.pageScrollOptions=e}return t.getScrollingTargetPosition=function(e,t){var n=e.document.body,o=e.document.documentElement,r=e.document.defaultView&&e.document.defaultView.pageYOffset||undefined,i=e.document.defaultView&&e.document.defaultView.pageXOffset||undefined,l=r||o.scrollTop||n.scrollTop,s=i||o.scrollLeft||n.scrollLeft,c=o.clientTop||n.clientTop||0,a=o.clientLeft||n.clientLeft||0;if(t===undefined||null===t)return{top:l,left:s};var p=t.getBoundingClientRect(),u=p.top+l-c,g=p.left+s-a;return{top:Math.round(u),left:Math.round(g)}},t.getInlineScrollingTargetPosition=function(e,t){var n={top:t.offsetTop,left:t.offsetLeft};if(e.advancedInlineOffsetCalculation&&1===e.scrollViews.length){for(var o={top:0,left:0},r=t.ownerDocument.defaultView,i=!1,l=t.parentElement;!i&&l!==undefined&&null!==l;)"relative"===r.getComputedStyle(l).getPropertyValue("position")&&(o.top+=l.offsetTop,o.left+=l.offsetLeft),i=(l=l.parentElement)===e.scrollViews[0];i&&(n.top+=o.top,n.left+=o.left)}return n},t.prototype.getScrollPropertyValue=function(e){return this.pageScrollOptions.verticalScrolling?e.scrollTop:e.scrollLeft},t.prototype.extractScrollTargetPosition=function(){var e=this.getScrollTargetElement();return null===e||e===undefined?{top:NaN,left:NaN}:this.isInlineScrolling?t.getInlineScrollingTargetPosition(this.pageScrollOptions,e):t.getScrollingTargetPosition(this.pageScrollOptions,e)},t.prototype.getCurrentOffset=function(){return this.pageScrollOptions.scrollOffset},t.prototype.setScrollPosition=function(i){var l=this;return this.pageScrollOptions.scrollViews.reduce(function(e,t){var n=l.getScrollPropertyValue(t);if(t&&n!==undefined&&null!==n){var o=Math.abs(n-i),r=o<l.pageScrollOptions._minScrollDistance;if(l.pageScrollOptions.verticalScrolling?t.scrollTop=i:t.scrollLeft=i,r||o>Math.abs(l.getScrollPropertyValue(t)-i))return!0}return e},!1)},t.prototype.fireEvent=function(e){this.pageScrollOptions.scrollFinishListener&&this.pageScrollOptions.scrollFinishListener.emit(e)},t.prototype.attachInterruptListeners=function(t){var n=this;this.interruptListenersAttached&&this.detachInterruptListeners(),this.interruptListener=function(e){t.report(e,n)},this.pageScrollOptions.interruptEvents.forEach(function(e){return n.pageScrollOptions.document.body.addEventListener(e,n.interruptListener)}),this.interruptListenersAttached=!0},t.prototype.detachInterruptListeners=function(){var t=this;this.pageScrollOptions.interruptEvents.forEach(function(e){return t.pageScrollOptions.document.body.removeEventListener(e,t.interruptListener)}),this.interruptListenersAttached=!1},t.prototype.getScrollTargetElement=function(){if("string"!=typeof this.pageScrollOptions.scrollTarget)return this.pageScrollOptions.scrollTarget;var e=this.pageScrollOptions.scrollTarget;return null!==e.match(/^#[^\s]+$/g)?this.pageScrollOptions.document.getElementById(e.substr(1)):this.pageScrollOptions.document.querySelector(e)},t}(),o=new s.InjectionToken("ngxps_config"),r={_interval:10,_minScrollDistance:2,_logLevel:1,namespace:"default",verticalScrolling:!0,duration:1250,scrollOffset:0,advancedInlineOffsetCalculation:!1,interruptEvents:["mousedown","wheel","DOMMouseScroll","mousewheel","keyup","touchmove"],interruptKeys:[" ","Escape","Tab","Enter","PageUp","PageDown","Home","End","ArrowUp","ArrowRight","ArrowLeft","ArrowDown"],interruptible:!0,easingLogic:function(e,t,n,o){return n*e/o+t}},i=function(){function t(e){var o=this;this.runningInstances=[],this.onInterrupted={report:function(t,e){if(e.pageScrollOptions.interruptible){var n=!0;"keyup"===t.type?-1===o.config.interruptKeys.indexOf(t.key)&&(n=!1):"mousedown"===t.type&&(e.pageScrollOptions.scrollViews.some(function(e){return e.contains(t.target)})||(n=!1)),n&&o.stopAll(e.pageScrollOptions.namespace)}}},this.config=c({},r,e),0<t.instanceCounter&&(2<=this.config._logLevel||1<=this.config._logLevel&&s.isDevMode())&&console.warn("An instance of PageScrollService already exists, usually including one provider should be enough, so double check."),t.instanceCounter++}return t.prototype.stopInternal=function(e,t){var n=this.runningInstances.indexOf(t);return 0<=n&&this.runningInstances.splice(n,1),t.interruptListenersAttached&&t.detachInterruptListeners(),!!t.timer&&(clearInterval(t.timer),t.timer=undefined,t.fireEvent(!e),!0)},t.prototype.create=function(e){return new n(c({},this.config,e))},t.prototype.start=function(n){var r=this;if(n.pageScrollOptions=c({},this.config,n.pageScrollOptions),this.stopAll(n.pageScrollOptions.namespace),null!==n.pageScrollOptions.scrollViews&&0!==n.pageScrollOptions.scrollViews.length){var o=!1;n.startScrollPosition=0,n.pageScrollOptions.scrollViews.forEach(function(e){if(e!==undefined&&null!==e){var t=n.getScrollPropertyValue(e);!o&&t&&(n.startScrollPosition=t,o=!0)}});var e=n.getCurrentOffset(),t=n.extractScrollTargetPosition();if(n.targetScrollPosition=Math.round((n.pageScrollOptions.verticalScrolling?t.top:t.left)-e),n.distanceToScroll=n.targetScrollPosition-n.startScrollPosition,isNaN(n.distanceToScroll))return(2<=this.config._logLevel||1<=this.config._logLevel&&s.isDevMode())&&console.log("Scrolling not possible, as we can't find the specified target"),void n.fireEvent(!1);var i=Math.abs(n.distanceToScroll)<n.pageScrollOptions._minScrollDistance;n.executionDuration=n.pageScrollOptions.duration,n.pageScrollOptions.speed===undefined||null===n.pageScrollOptions.speed||n.pageScrollOptions.duration!==undefined&&null!==n.pageScrollOptions.duration||(n.executionDuration=Math.abs(n.distanceToScroll)/n.pageScrollOptions.speed*1e3);var l=n.executionDuration<=n.pageScrollOptions._interval;if(i||l)return(2<=this.config._logLevel||1<=this.config._logLevel&&s.isDevMode())&&(i?console.log("Scrolling not possible, as we can't get any closer to the destination"):console.log("Scroll duration shorter that interval length, jumping to target")),n.setScrollPosition(n.targetScrollPosition),void n.fireEvent(!0);n.pageScrollOptions.interruptible&&n.attachInterruptListeners(this.onInterrupted),n.startTime=(new Date).getTime(),n.endTime=n.startTime+n.executionDuration,n.timer=setInterval(function(e){var t,n=(new Date).getTime(),o=!1;e.endTime<=n?(t=e.targetScrollPosition,o=!0):t=Math.round(e.pageScrollOptions.easingLogic(n-e.startTime,e.startScrollPosition,e.distanceToScroll,e.executionDuration)),5<=r.config._logLevel&&s.isDevMode()&&console.warn("Scroll Position: "+t),e.setScrollPosition(t)||(o=!0),o&&r.stopInternal(!1,e)},this.config._interval,n),this.runningInstances.push(n)}else(2<=this.config._logLevel||1<=this.config._logLevel&&s.isDevMode())&&console.warn("No scrollViews specified, thus ngx-page-scroll does not know which DOM elements to scroll")},t.prototype.scroll=function(e){this.start(this.create(e))},t.prototype.stopAll=function(e){if(0<this.runningInstances.length){for(var t=!1,n=0;n<this.runningInstances.length;++n){var o=this.runningInstances[n];e&&o.pageScrollOptions.namespace!==e||(t=!0,this.stopInternal(!0,o),n--)}return t}return!1},t.prototype.stop=function(e){return this.stopInternal(!0,e)},t.instanceCounter=0,t.decorators=[{type:s.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:undefined,decorators:[{type:s.Inject,args:[o]}]}]},t.ngInjectableDef=s.defineInjectable({factory:function(){return new t(s.inject(o))},token:t,providedIn:"root"}),t}(),l={},t=function(){function t(){}return t.forRoot=function(e){return{ngModule:t,providers:[i,{provide:o,useValue:e}]}},t.decorators=[{type:s.NgModule,args:[{providers:[i,{provide:o,useValue:l}]}]}],t}();e.NgxPageScrollCoreModule=t,e.NGXPS_CONFIG=o,e.defaultPageScrollConfig=r,e.PageScrollService=i,e.PageScrollInstance=n,Object.defineProperty(e,"__esModule",{value:!0})});
  //# sourceMappingURL=ngx-page-scroll-core.umd.min.js.map