ngx-page-scroll
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -17,5 +17,3 @@ (function (global, factory) { | ||
// Getter and setter to avoid auto completion to suggest calling the method | ||
get: | ||
// Getter and setter to avoid auto completion to suggest calling the method | ||
function () { | ||
get: function () { | ||
return PageScrollConfig._easingLogic; | ||
@@ -30,73 +28,73 @@ }, | ||
/** | ||
* The number of milliseconds to wait till updating the scroll position again. | ||
* Small amounts may produce smoother animations but require more processing power. | ||
* @type {number} | ||
*/ | ||
* The number of milliseconds to wait till updating the scroll position again. | ||
* Small amounts may produce smoother animations but require more processing power. | ||
* @type {number} | ||
*/ | ||
PageScrollConfig._interval = 10; | ||
/** | ||
* The amount of pixels that need to be between the current scrollTop/scrollLeft position | ||
* and the target position the cause a scroll animation. In case distance is below | ||
* this threshold, an immediate jump will be performed. | ||
* Due to dpi or rounding irregularities in browsers floating point numbers for scrollTop/scrollLeft values | ||
* are possible, making a === comparison of current scrollTop or scrollLeft and target scrollPosition error-prone. | ||
* @type {number} | ||
*/ | ||
* The amount of pixels that need to be between the current scrollTop/scrollLeft position | ||
* and the target position the cause a scroll animation. In case distance is below | ||
* this threshold, an immediate jump will be performed. | ||
* Due to dpi or rounding irregularities in browsers floating point numbers for scrollTop/scrollLeft values | ||
* are possible, making a === comparison of current scrollTop or scrollLeft and target scrollPosition error-prone. | ||
* @type {number} | ||
*/ | ||
PageScrollConfig._minScrollDistance = 2; | ||
/** | ||
* Name of the default namespace. | ||
* @type {string} | ||
*/ | ||
* Name of the default namespace. | ||
* @type {string} | ||
*/ | ||
PageScrollConfig._defaultNamespace = 'default'; | ||
/** | ||
* Whether by default the scrolling should happen in vertical direction (by manipulating the scrollTop property) | ||
* (= true; default) or in horizontal direction (by manipulating the scrollLeft property) (= false | ||
* @type {boolean} | ||
*/ | ||
* Whether by default the scrolling should happen in vertical direction (by manipulating the scrollTop property) | ||
* (= true; default) or in horizontal direction (by manipulating the scrollLeft property) (= false | ||
* @type {boolean} | ||
*/ | ||
PageScrollConfig.defaultIsVerticalScrolling = true; | ||
/** | ||
* How many console logs should be emitted. Also influenced by angular mode (dev or prod mode) | ||
* 0: No logs, neither in dev nor in prod mode | ||
* 1: Animation errors in dev mode, no logs in prod mode | ||
* 2: Animation errors in dev and prod mode | ||
* 5: Animation errors in dev and all scroll position values that get set; animation errors in prod mode | ||
* @type {number} | ||
*/ | ||
* How many console logs should be emitted. Also influenced by angular mode (dev or prod mode) | ||
* 0: No logs, neither in dev nor in prod mode | ||
* 1: Animation errors in dev mode, no logs in prod mode | ||
* 2: Animation errors in dev and prod mode | ||
* 5: Animation errors in dev and all scroll position values that get set; animation errors in prod mode | ||
* @type {number} | ||
*/ | ||
PageScrollConfig._logLevel = 1; | ||
/** | ||
* The duration how long a scrollTo animation should last by default. | ||
* May be overridden using the page-scroll-duration attribute on a single ngxPageScroll instance. | ||
* @type {number} | ||
*/ | ||
* The duration how long a scrollTo animation should last by default. | ||
* May be overridden using the page-scroll-duration attribute on a single ngxPageScroll instance. | ||
* @type {number} | ||
*/ | ||
PageScrollConfig.defaultDuration = 1250; | ||
/** | ||
* The distance in pixels above scroll target where the animation should stop. Setting a positive number results in | ||
* the scroll target being more in the middle of the screen, negative numbers will produce scrolling "too far" | ||
* @type {number} | ||
*/ | ||
* The distance in pixels above scroll target where the animation should stop. Setting a positive number results in | ||
* the scroll target being more in the middle of the screen, negative numbers will produce scrolling "too far" | ||
* @type {number} | ||
*/ | ||
PageScrollConfig.defaultScrollOffset = 0; | ||
/** | ||
* Whether by default for inline scroll animations the advanced offset calculation should take place (true) or | ||
* not (false). Default is false. | ||
* The advanced offset calculation will traverse the DOM tree upwards, starting at the scrollTarget, until it finds | ||
* the scrollingView container element. Along the way the offset positions of the relative positioned | ||
* (position: relative) elements will be taken into account for calculating the target elements position. | ||
* @type {boolean} | ||
*/ | ||
* Whether by default for inline scroll animations the advanced offset calculation should take place (true) or | ||
* not (false). Default is false. | ||
* The advanced offset calculation will traverse the DOM tree upwards, starting at the scrollTarget, until it finds | ||
* the scrollingView container element. Along the way the offset positions of the relative positioned | ||
* (position: relative) elements will be taken into account for calculating the target elements position. | ||
* @type {boolean} | ||
*/ | ||
PageScrollConfig.defaultAdvancedInlineOffsetCalculation = false; | ||
/** | ||
* The events that are listened to on the body to decide whether a scroll animation has been interfered/interrupted by the user | ||
* @type {string[]} | ||
*/ | ||
* The events that are listened to on the body to decide whether a scroll animation has been interfered/interrupted by the user | ||
* @type {string[]} | ||
*/ | ||
PageScrollConfig._interruptEvents = ['mousedown', 'wheel', 'DOMMouseScroll', 'mousewheel', 'keyup', 'touchmove']; | ||
/** | ||
* The keys that are considered to interrupt a scroll animation (mainly the arrow keys). All other key presses will not stop the | ||
* scroll animation. | ||
* @type {number[]} | ||
*/ | ||
* The keys that are considered to interrupt a scroll animation (mainly the arrow keys). All other key presses will not stop the | ||
* scroll animation. | ||
* @type {number[]} | ||
*/ | ||
PageScrollConfig._interruptKeys = [33, 34, 35, 36, 38, 40]; | ||
/** | ||
* Whether a scroll animation should be interruptible by user interaction (true) or not (false). If the user performs an | ||
* interrupting event while a scroll animation takes place, the scroll animation stops. | ||
* @type {boolean} | ||
*/ | ||
* Whether a scroll animation should be interruptible by user interaction (true) or not (false). If the user performs an | ||
* interrupting event while a scroll animation takes place, the scroll animation stops. | ||
* @type {boolean} | ||
*/ | ||
PageScrollConfig.defaultInterruptible = true; | ||
@@ -120,13 +118,3 @@ PageScrollConfig._easingLogic = { | ||
*/ | ||
/** | ||
* Util method to check whether a given variable is either undefined or null | ||
* @param variable | ||
* @returns {boolean} true the variable is undefined or null | ||
*/ | ||
PageScrollUtilService.isUndefinedOrNull = /** | ||
* Util method to check whether a given variable is either undefined or null | ||
* @param variable | ||
* @returns {boolean} true the variable is undefined or null | ||
*/ | ||
function (variable) { | ||
PageScrollUtilService.isUndefinedOrNull = function (variable) { | ||
return (typeof variable === 'undefined') || variable === undefined || variable === null; | ||
@@ -155,2 +143,11 @@ }; | ||
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var PageScrollService = /** @class */ (function () { | ||
@@ -187,3 +184,3 @@ function PageScrollService() { | ||
}; | ||
if (PageScrollService.instanceCounter > 0 && | ||
if (PageScrollService_1.instanceCounter > 0 && | ||
(PageScrollConfig._logLevel >= 2 || (PageScrollConfig._logLevel >= 1 && core.isDevMode()))) { | ||
@@ -193,4 +190,5 @@ console.warn('An instance of PageScrollService already exists, usually ' + | ||
} | ||
PageScrollService.instanceCounter++; | ||
PageScrollService_1.instanceCounter++; | ||
} | ||
PageScrollService_1 = PageScrollService; | ||
PageScrollService.prototype.stopInternal = function (interrupted, pageScrollInstance) { | ||
@@ -221,17 +219,3 @@ var index = this.runningInstances.indexOf(pageScrollInstance); | ||
*/ | ||
/** | ||
* Start a scroll animation. All properties of the animation are stored in the given {@link PageScrollInstance} object. | ||
* | ||
* This is the core functionality of the whole library. | ||
* | ||
* @param pageScrollInstance | ||
*/ | ||
PageScrollService.prototype.start = /** | ||
* Start a scroll animation. All properties of the animation are stored in the given {@link PageScrollInstance} object. | ||
* | ||
* This is the core functionality of the whole library. | ||
* | ||
* @param pageScrollInstance | ||
*/ | ||
function (pageScrollInstance) { | ||
PageScrollService.prototype.start = function (pageScrollInstance) { | ||
var _this = this; | ||
@@ -352,15 +336,3 @@ // Stop all possibly running scroll animations in the same namespace | ||
*/ | ||
/** | ||
* Stop all running scroll animations. Optionally limit to stop only the ones of specific namespace. | ||
* | ||
* @param namespace | ||
* @returns {boolean} | ||
*/ | ||
PageScrollService.prototype.stopAll = /** | ||
* Stop all running scroll animations. Optionally limit to stop only the ones of specific namespace. | ||
* | ||
* @param namespace | ||
* @returns {boolean} | ||
*/ | ||
function (namespace) { | ||
PageScrollService.prototype.stopAll = function (namespace) { | ||
if (this.runningInstances.length > 0) { | ||
@@ -385,8 +357,8 @@ var stoppedSome = false; | ||
}; | ||
var PageScrollService_1; | ||
PageScrollService.instanceCounter = 0; | ||
PageScrollService.decorators = [ | ||
{ type: core.Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
PageScrollService.ctorParameters = function () { return []; }; | ||
PageScrollService = PageScrollService_1 = __decorate([ | ||
core.Injectable(), | ||
__metadata("design:paramtypes", []) | ||
], PageScrollService); | ||
return PageScrollService; | ||
@@ -407,6 +379,3 @@ }()); | ||
*/ | ||
var /** | ||
* Represents a scrolling action | ||
*/ | ||
PageScrollInstance = /** @class */ (function () { | ||
var PageScrollInstance = /** @class */ (function () { | ||
/** | ||
@@ -422,4 +391,4 @@ * Private constructor, requires the properties assumed to be the bare minimum. | ||
/** | ||
* These properties will be set during instance construction and default to their defaults from PageScrollConfig | ||
*/ | ||
* These properties will be set during instance construction and default to their defaults from PageScrollConfig | ||
*/ | ||
/* A namespace to "group" scroll animations together and stopping some does not stop others */ | ||
@@ -442,4 +411,4 @@ this._namespace = PageScrollConfig._defaultNamespace; | ||
/** | ||
* These properties will be set/manipulated if the scroll animation starts | ||
*/ | ||
* These properties will be set/manipulated if the scroll animation starts | ||
*/ | ||
/* The initial value of the scrollTop or scrollLeft position when the animation starts */ | ||
@@ -450,3 +419,3 @@ this._startScrollPosition = 0; | ||
/* References to the timer instance that is used to perform the scroll animation to be | ||
able to clear it on animation end*/ | ||
able to clear it on animation end*/ | ||
this._timer = null; | ||
@@ -459,9 +428,3 @@ this._namespace = namespace; | ||
*/ | ||
/* | ||
* Factory methods for instance creation | ||
*/ | ||
PageScrollInstance.simpleInstance = /* | ||
* Factory methods for instance creation | ||
*/ | ||
function (document, scrollTarget, namespace) { | ||
PageScrollInstance.simpleInstance = function (document, scrollTarget, namespace) { | ||
return PageScrollInstance.newInstance({ | ||
@@ -528,19 +491,3 @@ document: document, | ||
*/ | ||
/** | ||
* Extract the exact location of the scrollTarget element. | ||
* | ||
* Extract the scrollTarget HTMLElement from the given PageScrollTarget object. The latter one may be | ||
* a string like "#heading2", then this method returns the corresponding DOM element for that id. | ||
* | ||
* @returns {HTMLElement} | ||
*/ | ||
PageScrollInstance.prototype.extractScrollTargetPosition = /** | ||
* Extract the exact location of the scrollTarget element. | ||
* | ||
* Extract the scrollTarget HTMLElement from the given PageScrollTarget object. The latter one may be | ||
* a string like "#heading2", then this method returns the corresponding DOM element for that id. | ||
* | ||
* @returns {HTMLElement} | ||
*/ | ||
function () { | ||
PageScrollInstance.prototype.extractScrollTargetPosition = function () { | ||
var scrollTargetElement; | ||
@@ -580,3 +527,2 @@ if (typeof this._scrollTarget === 'string') { | ||
// Next iteration | ||
// Next iteration | ||
parent_1 = parent_1.parentElement; | ||
@@ -607,17 +553,3 @@ parentFound = parent_1 === this.scrollingViews[0]; | ||
*/ | ||
/** | ||
* Get the top offset of the scroll animation. | ||
* This automatically takes the offset location of the scrolling container/scrolling view | ||
* into account (for nested/inline scrolling). | ||
* | ||
* @returns {number} | ||
*/ | ||
PageScrollInstance.prototype.getCurrentOffset = /** | ||
* Get the top offset of the scroll animation. | ||
* This automatically takes the offset location of the scrolling container/scrolling view | ||
* into account (for nested/inline scrolling). | ||
* | ||
* @returns {number} | ||
*/ | ||
function () { | ||
PageScrollInstance.prototype.getCurrentOffset = function () { | ||
return this._offset; | ||
@@ -632,17 +564,3 @@ }; | ||
*/ | ||
/** | ||
* Sets the "scrollTop" or "scrollLeft" property for all scrollingViews to the provided value | ||
* @param position | ||
* @return true if at least for one ScrollTopSource the scrollTop/scrollLeft value could be set and it kept the new value. | ||
* false if it failed for all ScrollingViews, meaning that we should stop the animation | ||
* (probably because we're at the end of the scrolling region) | ||
*/ | ||
PageScrollInstance.prototype.setScrollPosition = /** | ||
* Sets the "scrollTop" or "scrollLeft" property for all scrollingViews to the provided value | ||
* @param position | ||
* @return true if at least for one ScrollTopSource the scrollTop/scrollLeft value could be set and it kept the new value. | ||
* false if it failed for all ScrollingViews, meaning that we should stop the animation | ||
* (probably because we're at the end of the scrolling region) | ||
*/ | ||
function (position) { | ||
PageScrollInstance.prototype.setScrollPosition = function (position) { | ||
var _this = this; | ||
@@ -684,11 +602,3 @@ if (PageScrollConfig._logLevel >= 5 && core.isDevMode()) { | ||
*/ | ||
/** | ||
* Trigger firing a animation finish event | ||
* @param value Whether the animation finished at the target (true) or got interrupted (false) | ||
*/ | ||
PageScrollInstance.prototype.fireEvent = /** | ||
* Trigger firing a animation finish event | ||
* @param value Whether the animation finished at the target (true) or got interrupted (false) | ||
*/ | ||
function (value) { | ||
PageScrollInstance.prototype.fireEvent = function (value) { | ||
if (this._pageScrollFinish) { | ||
@@ -706,19 +616,3 @@ this._pageScrollFinish.emit(value); | ||
*/ | ||
/** | ||
* Attach the interrupt listeners to the PageScrollInstance body. The given interruptReporter | ||
* will be called if any of the attached events is fired. | ||
* | ||
* Possibly attached interruptListeners are automatically removed from the body before the new one will be attached. | ||
* | ||
* @param interruptReporter | ||
*/ | ||
PageScrollInstance.prototype.attachInterruptListeners = /** | ||
* Attach the interrupt listeners to the PageScrollInstance body. The given interruptReporter | ||
* will be called if any of the attached events is fired. | ||
* | ||
* Possibly attached interruptListeners are automatically removed from the body before the new one will be attached. | ||
* | ||
* @param interruptReporter | ||
*/ | ||
function (interruptReporter) { | ||
PageScrollInstance.prototype.attachInterruptListeners = function (interruptReporter) { | ||
var _this = this; | ||
@@ -739,11 +633,3 @@ if (this._interruptListenersAttached) { | ||
*/ | ||
/** | ||
* Remove event listeners from the body and stop listening for events that might be treated as "animation | ||
* interrupt" events. | ||
*/ | ||
PageScrollInstance.prototype.detachInterruptListeners = /** | ||
* Remove event listeners from the body and stop listening for events that might be treated as "animation | ||
* interrupt" events. | ||
*/ | ||
function () { | ||
PageScrollInstance.prototype.detachInterruptListeners = function () { | ||
var _this = this; | ||
@@ -889,2 +775,14 @@ PageScrollConfig._interruptEvents.forEach(function (event) { return _this.document.body.removeEventListener(event, _this._interruptListener); }); | ||
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (undefined && undefined.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
var PageScroll = /** @class */ (function () { | ||
@@ -950,3 +848,2 @@ function PageScroll(pageScrollService, router$$1, document) { | ||
var _this = this; | ||
// tslint:disable-line:no-unused-variable | ||
if (this.routerLink && this.router !== null && this.router !== undefined) { | ||
@@ -982,45 +879,80 @@ var urlTree = void 0; | ||
}; | ||
PageScroll.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
selector: '[pageScroll]', | ||
host: { | ||
// tslint:disable-line:use-host-property-decorator | ||
'(click)': 'handleClick($event)', | ||
} | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
PageScroll.ctorParameters = function () { return [ | ||
{ type: PageScrollService, }, | ||
{ type: router.Router, decorators: [{ type: core.Optional },] }, | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] },] }, | ||
]; }; | ||
PageScroll.propDecorators = { | ||
"routerLink": [{ type: core.Input },], | ||
"href": [{ type: core.Input },], | ||
"pageScrollTarget": [{ type: core.Input },], | ||
"pageScrollHorizontal": [{ type: core.Input },], | ||
"pageScrollOffset": [{ type: core.Input },], | ||
"pageScrollDuration": [{ type: core.Input },], | ||
"pageScrollSpeed": [{ type: core.Input },], | ||
"pageScrollEasing": [{ type: core.Input },], | ||
"pageScrollInterruptible": [{ type: core.Input },], | ||
"pageScrollAdjustHash": [{ type: core.Input },], | ||
"pageScroll": [{ type: core.Input },], | ||
"pageScrollFinish": [{ type: core.Output },], | ||
}; | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Object) | ||
], PageScroll.prototype, "routerLink", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", String) | ||
], PageScroll.prototype, "href", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", String) | ||
], PageScroll.prototype, "pageScrollTarget", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Boolean) | ||
], PageScroll.prototype, "pageScrollHorizontal", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Number) | ||
], PageScroll.prototype, "pageScrollOffset", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Number) | ||
], PageScroll.prototype, "pageScrollDuration", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Number) | ||
], PageScroll.prototype, "pageScrollSpeed", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", EasingLogic) | ||
], PageScroll.prototype, "pageScrollEasing", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Boolean) | ||
], PageScroll.prototype, "pageScrollInterruptible", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", Object) | ||
], PageScroll.prototype, "pageScrollAdjustHash", void 0); | ||
__decorate$1([ | ||
core.Input(), | ||
__metadata$1("design:type", String) | ||
], PageScroll.prototype, "pageScroll", void 0); | ||
__decorate$1([ | ||
core.Output(), | ||
__metadata$1("design:type", core.EventEmitter) | ||
], PageScroll.prototype, "pageScrollFinish", void 0); | ||
PageScroll = __decorate$1([ | ||
core.Directive({ | ||
selector: '[pageScroll]', | ||
host: { | ||
'(click)': 'handleClick($event)', | ||
} | ||
}), | ||
__param(1, core.Optional()), __param(2, core.Inject(common.DOCUMENT)), | ||
__metadata$1("design:paramtypes", [PageScrollService, router.Router, Object]) | ||
], PageScroll); | ||
return PageScroll; | ||
}()); | ||
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var NgxPageScrollModule = /** @class */ (function () { | ||
function NgxPageScrollModule() { | ||
} | ||
NgxPageScrollModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
imports: [common.CommonModule], | ||
declarations: [PageScroll], | ||
exports: [PageScroll], | ||
providers: [NgxPageScrollServiceProvider] | ||
},] }, | ||
]; | ||
NgxPageScrollModule = __decorate$2([ | ||
core.NgModule({ | ||
imports: [common.CommonModule], | ||
declarations: [PageScroll], | ||
exports: [PageScroll], | ||
providers: [NgxPageScrollServiceProvider] | ||
}) | ||
], NgxPageScrollModule); | ||
return NgxPageScrollModule; | ||
@@ -1027,0 +959,0 @@ }()); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/router"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@angular/common"],t):t((e.ngx=e.ngx||{},e.ngx.page=e.ngx.page||{},e.ngx.page.scroll={}),e.ng.core,e.ng.router,e.ng.common)}(this,function(e,t,n,r){"use strict";var i=function(){return function(){}}(),o=function(){function e(){}return Object.defineProperty(e,"defaultEasingLogic",{get:function(){return e._easingLogic},set:function(t){e._easingLogic=t},enumerable:!0,configurable:!0}),e._interval=10,e._minScrollDistance=2,e._defaultNamespace="default",e.defaultIsVerticalScrolling=!0,e._logLevel=1,e.defaultDuration=1250,e.defaultScrollOffset=0,e.defaultAdvancedInlineOffsetCalculation=!1,e._interruptEvents=["mousedown","wheel","DOMMouseScroll","mousewheel","keyup","touchmove"],e._interruptKeys=[33,34,35,36,38,40],e.defaultInterruptible=!0,e._easingLogic={ease:function(e,t,n,r){return n*e/r+t}},e}(),l=function(){function e(){}return e.isUndefinedOrNull=function(e){return void 0===e||void 0===e||null===e},e.extractElementPosition=function(t,n){var r=t.body,i=t.documentElement,o=t.defaultView&&t.defaultView.pageYOffset||void 0,l=t.defaultView&&t.defaultView.pageXOffset||void 0,s=o||i.scrollTop||r.scrollTop,a=l||i.scrollLeft||r.scrollLeft,c=i.clientTop||r.clientTop||0,u=i.clientLeft||r.clientLeft||0;if(e.isUndefinedOrNull(n))return{top:s,left:a};var p=n.getBoundingClientRect(),g=p.top+s-c,f=p.left+a-u;return{top:Math.round(g),left:Math.round(f)}},e}(),s=function(){function e(){var n=this;this.runningInstances=[],this.onInterrupted={report:function(e,t){if(t.interruptible){var r=!0;"keyup"===e.type?-1===o._interruptKeys.indexOf(e.keyCode)&&(r=!1):"mousedown"===e.type&&(t.scrollingViews.some(function(t){return t.contains(e.target)})||(r=!1)),r&&n.stopAll(t.namespace)}}},e.instanceCounter>0&&(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.warn("An instance of PageScrollService already exists, usually including one provider should be enough, so double check."),e.instanceCounter++}return e.prototype.stopInternal=function(e,t){var n=this.runningInstances.indexOf(t);return n>=0&&this.runningInstances.splice(n,1),t.interruptListenersAttached&&t.detachInterruptListeners(),!!t.timer&&(clearInterval(t.timer),t.timer=void 0,t.fireEvent(!e),!0)},e.prototype.start=function(e){var n=this;if(this.stopAll(e.namespace),null!==e.scrollingViews&&0!==e.scrollingViews.length){var r=!1;e.startScrollPosition=0,e.scrollingViews.forEach(function(t){if(!l.isUndefinedOrNull(t)){var n=e.getScrollPropertyValue(t);!r&&n&&(e.startScrollPosition=n,r=!0)}});var i=e.getCurrentOffset(),s=e.extractScrollTargetPosition();if(e.targetScrollPosition=Math.round((e.verticalScrolling?s.top:s.left)-i),e.distanceToScroll=e.targetScrollPosition-e.startScrollPosition,isNaN(e.distanceToScroll))return(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.log("Scrolling not possible, as we can't find the specified target"),void e.fireEvent(!1);var a=Math.abs(e.distanceToScroll)<o._minScrollDistance;e.executionDuration=e.duration,!l.isUndefinedOrNull(e.speed)&&l.isUndefinedOrNull(e.duration)&&(e.executionDuration=Math.abs(e.distanceToScroll)/e.speed*1e3);var c=e.executionDuration<=o._interval;if(a||c)return(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&(a?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")),e.setScrollPosition(e.targetScrollPosition),void e.fireEvent(!0);(e.interruptible||l.isUndefinedOrNull(e.interruptible)&&o.defaultInterruptible)&&e.attachInterruptListeners(this.onInterrupted),e.startTime=(new Date).getTime(),e.endTime=e.startTime+e.executionDuration,e.timer=setInterval(function(e){var t,r=(new Date).getTime(),i=!1;e.endTime<=r?(t=e.targetScrollPosition,i=!0):t=Math.round(e.easingLogic.ease(r-e.startTime,e.startScrollPosition,e.distanceToScroll,e.executionDuration)),e.setScrollPosition(t)||(i=!0),i&&n.stopInternal(!1,e)},o._interval,e),this.runningInstances.push(e)}else(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.warn("No scrollingViews specified, this ngx-page-scroll does not know which DOM elements to scroll")},e.prototype.stopAll=function(e){if(this.runningInstances.length>0){for(var t=!1,n=0;n<this.runningInstances.length;++n){var r=this.runningInstances[n];(l.isUndefinedOrNull(e)||0===e.length||r.namespace===e)&&(t=!0,this.stopInternal(!0,r),n--)}return t}return!1},e.prototype.stop=function(e){return this.stopInternal(!0,e)},e.instanceCounter=0,e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[]},e}();function a(e){return e||new s}var c={provide:s,deps:[[new t.Optional,new t.SkipSelf,s]],useFactory:a},u=function(){function e(e,n){this._namespace=o._defaultNamespace,this._verticalScrolling=o.defaultIsVerticalScrolling,this._offset=o.defaultScrollOffset,this._duration=o.defaultDuration,this._easingLogic=o.defaultEasingLogic,this._interruptible=o.defaultInterruptible,this._advancedInlineOffsetCalculation=o.defaultAdvancedInlineOffsetCalculation,this._pageScrollFinish=new t.EventEmitter,this._startScrollPosition=0,this._interruptListenersAttached=!1,this._timer=null,this._namespace=e,this.document=n}return e.simpleInstance=function(t,n,r){return e.newInstance({document:t,scrollTarget:n,namespace:r})},e.newInstance=function(t){(l.isUndefinedOrNull(t.namespace)||t.namespace.length<=0)&&(t.namespace=o._defaultNamespace);var n=new e(t.namespace,document);return l.isUndefinedOrNull(t.scrollingViews)||0===t.scrollingViews.length?(n._isInlineScrolling=!1,n._scrollingViews=[document.documentElement,document.body,document.body.parentNode]):(n._isInlineScrolling=!0,n._scrollingViews=t.scrollingViews),n._scrollTarget=t.scrollTarget,l.isUndefinedOrNull(t.verticalScrolling)||(n._verticalScrolling=t.verticalScrolling),l.isUndefinedOrNull(t.pageScrollOffset)||(n._offset=t.pageScrollOffset),l.isUndefinedOrNull(t.pageScrollEasingLogic)||(n._easingLogic=t.pageScrollEasingLogic),l.isUndefinedOrNull(t.pageScrollDuration)&&!l.isUndefinedOrNull(t.pageScrollSpeed)?(n._speed=t.pageScrollSpeed,n._duration=void 0):l.isUndefinedOrNull(t.pageScrollDuration)||(n._duration=t.pageScrollDuration),l.isUndefinedOrNull(t.pageScrollFinishListener)||(n._pageScrollFinish=t.pageScrollFinishListener),n._interruptible=t.pageScrollInterruptible||l.isUndefinedOrNull(t.pageScrollInterruptible)&&o.defaultInterruptible,n._advancedInlineOffsetCalculation=t.advancedInlineOffsetCalculation||l.isUndefinedOrNull(t.advancedInlineOffsetCalculation)&&o.defaultAdvancedInlineOffsetCalculation,n},e.prototype.getScrollPropertyValue=function(e){return this.verticalScrolling?e.scrollTop:e.scrollLeft},e.prototype.extractScrollTargetPosition=function(){var e;if("string"==typeof this._scrollTarget){var n=this._scrollTarget;e=null!==n.match(/^#[^\s]+$/g)?this.document.getElementById(n.substr(1)):this.document.querySelector(n)}else e=this._scrollTarget;if(null===e||void 0===e)return{top:NaN,left:NaN};if(this._isInlineScrolling){var r={top:e.offsetTop,left:e.offsetLeft};if(this._advancedInlineOffsetCalculation&&1===this.scrollingViews.length){for(var i={top:0,left:0},s=e.ownerDocument.defaultView,a=!1,c=e.parentElement;!a&&!l.isUndefinedOrNull(c);)"relative"===s.getComputedStyle(c).getPropertyValue("position")&&(i.top+=c.offsetTop,i.left+=c.offsetLeft),a=(c=c.parentElement)===this.scrollingViews[0];a?(r.top+=i.top,r.left+=i.left):(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.warn("Unable to find nested scrolling targets parent!")}return r}return l.extractElementPosition(this.document,e)},e.prototype.getCurrentOffset=function(){return this._offset},e.prototype.setScrollPosition=function(e){var n=this;return o._logLevel>=5&&t.isDevMode()&&console.warn("Scroll Position: "+e),this.scrollingViews.reduce(function(t,r){var i=n.getScrollPropertyValue(r);if(r&&!l.isUndefinedOrNull(i)){var s=Math.abs(i-e),a=s<o._minScrollDistance;if(n.verticalScrolling?r.scrollTop=e:r.scrollLeft=e,a||s>Math.abs(n.getScrollPropertyValue(r)-e))return!0}return t},!1)},e.prototype.fireEvent=function(e){this._pageScrollFinish&&this._pageScrollFinish.emit(e)},e.prototype.attachInterruptListeners=function(e){var t=this;this._interruptListenersAttached&&this.detachInterruptListeners(),this._interruptListener=function(n){e.report(n,t)},o._interruptEvents.forEach(function(e){return t.document.body.addEventListener(e,t._interruptListener)}),this._interruptListenersAttached=!0},e.prototype.detachInterruptListeners=function(){var e=this;o._interruptEvents.forEach(function(t){return e.document.body.removeEventListener(t,e._interruptListener)}),this._interruptListenersAttached=!1},Object.defineProperty(e.prototype,"namespace",{get:function(){return this._namespace},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollTarget",{get:function(){return this._scrollTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"verticalScrolling",{get:function(){return this._verticalScrolling},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollingViews",{get:function(){return this._scrollingViews},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startScrollPosition",{get:function(){return this._startScrollPosition},set:function(e){this._startScrollPosition=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetScrollPosition",{get:function(){return this._targetScrollPosition},set:function(e){this._targetScrollPosition=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distanceToScroll",{get:function(){return this._distanceToScroll},set:function(e){this._distanceToScroll=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"executionDuration",{get:function(){return this._executionDuration},set:function(e){this._executionDuration=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speed",{get:function(){return this._speed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"easingLogic",{get:function(){return this._easingLogic},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interruptible",{get:function(){return this._interruptible},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startTime",{get:function(){return this._startTime},set:function(e){this._startTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endTime",{get:function(){return this._endTime},set:function(e){this._endTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"timer",{get:function(){return this._timer},set:function(e){this._timer=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interruptListenersAttached",{get:function(){return this._interruptListenersAttached},enumerable:!0,configurable:!0}),e}(),p=function(){function e(e,n,r){this.pageScrollService=e,this.router=n,this.pageScrollTarget=null,this.pageScrollHorizontal=null,this.pageScrollOffset=null,this.pageScrollDuration=null,this.pageScrollSpeed=null,this.pageScrollEasing=null,this.pageScrollAdjustHash=!1,this.pageScroll=null,this.pageScrollFinish=new t.EventEmitter,this.document=r}return e.prototype.ngOnChanges=function(e){this.pageScrollInstance=void 0},e.prototype.ngOnDestroy=function(){this.pageScrollInstance&&this.pageScrollService.stop(this.pageScrollInstance)},e.prototype.generatePageScrollInstance=function(){return l.isUndefinedOrNull(this.pageScrollInstance)&&(this.pageScrollInstance=u.newInstance({document:this.document,scrollTarget:this.pageScrollTarget||this.href,scrollingViews:null,namespace:this.pageScroll,verticalScrolling:!this.pageScrollHorizontal,pageScrollOffset:this.pageScrollOffset,pageScrollInterruptible:this.pageScrollInterruptible,pageScrollEasingLogic:this.pageScrollEasing,pageScrollDuration:this.pageScrollDuration,pageScrollSpeed:this.pageScrollSpeed,pageScrollFinishListener:this.pageScrollFinish})),this.pageScrollInstance},e.prototype.pushRouterState=function(){this.pageScrollAdjustHash&&"string"==typeof this.pageScrollInstance.scrollTarget&&"#"===this.pageScrollInstance.scrollTarget.substr(0,1)&&this.router.navigate([],{fragment:this.pageScrollInstance.scrollTarget.substr(1),preserveQueryParams:!0})},e.prototype.scroll=function(){var e=this.generatePageScrollInstance();this.pushRouterState(),this.pageScrollService.start(e)},e.prototype.handleClick=function(e){var t=this;if(this.routerLink&&null!==this.router&&void 0!==this.router){var r=void 0;if(r="string"==typeof this.routerLink?this.router.parseUrl(this.routerLink):this.router.createUrlTree(this.routerLink),!this.router.isActive(r,!0)){var i=this.router.events.subscribe(function(e){e instanceof n.NavigationEnd?(i.unsubscribe(),setTimeout(function(){t.scroll()},0)):(e instanceof n.NavigationError||e instanceof n.NavigationCancel)&&i.unsubscribe()});return!1}}return this.scroll(),!1},e.decorators=[{type:t.Directive,args:[{selector:"[pageScroll]",host:{"(click)":"handleClick($event)"}}]}],e.ctorParameters=function(){return[{type:s},{type:n.Router,decorators:[{type:t.Optional}]},{type:void 0,decorators:[{type:t.Inject,args:[r.DOCUMENT]}]}]},e.propDecorators={routerLink:[{type:t.Input}],href:[{type:t.Input}],pageScrollTarget:[{type:t.Input}],pageScrollHorizontal:[{type:t.Input}],pageScrollOffset:[{type:t.Input}],pageScrollDuration:[{type:t.Input}],pageScrollSpeed:[{type:t.Input}],pageScrollEasing:[{type:t.Input}],pageScrollInterruptible:[{type:t.Input}],pageScrollAdjustHash:[{type:t.Input}],pageScroll:[{type:t.Input}],pageScrollFinish:[{type:t.Output}]},e}(),g=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[r.CommonModule],declarations:[p],exports:[p],providers:[c]}]}],e}();e.PageScroll=p,e.PageScrollService=s,e.NgxPageScrollServiceProviderFactory=a,e.NgxPageScrollServiceProvider=c,e.EasingLogic=i,e.PageScrollConfig=o,e.PageScrollInstance=u,e.PageScrollUtilService=l,e.NgxPageScrollModule=g,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/router"),require("@angular/common")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@angular/common"],t):t((e.ngx=e.ngx||{},e.ngx.page=e.ngx.page||{},e.ngx.page.scroll={}),e.ng.core,e.ng.router,e.ng.common)}(this,function(e,t,n,r){"use strict";var i=function(){return function(){}}(),o=function(){function e(){}return Object.defineProperty(e,"defaultEasingLogic",{get:function(){return e._easingLogic},set:function(t){e._easingLogic=t},enumerable:!0,configurable:!0}),e._interval=10,e._minScrollDistance=2,e._defaultNamespace="default",e.defaultIsVerticalScrolling=!0,e._logLevel=1,e.defaultDuration=1250,e.defaultScrollOffset=0,e.defaultAdvancedInlineOffsetCalculation=!1,e._interruptEvents=["mousedown","wheel","DOMMouseScroll","mousewheel","keyup","touchmove"],e._interruptKeys=[33,34,35,36,38,40],e.defaultInterruptible=!0,e._easingLogic={ease:function(e,t,n,r){return n*e/r+t}},e}(),l=function(){function e(){}return e.isUndefinedOrNull=function(e){return void 0===e||void 0===e||null===e},e.extractElementPosition=function(t,n){var r=t.body,i=t.documentElement,o=t.defaultView&&t.defaultView.pageYOffset||void 0,l=t.defaultView&&t.defaultView.pageXOffset||void 0,s=o||i.scrollTop||r.scrollTop,c=l||i.scrollLeft||r.scrollLeft,a=i.clientTop||r.clientTop||0,u=i.clientLeft||r.clientLeft||0;if(e.isUndefinedOrNull(n))return{top:s,left:c};var p=n.getBoundingClientRect(),f=p.top+s-a,g=p.left+c-u;return{top:Math.round(f),left:Math.round(g)}},e}(),s=function(e,t,n,r){var i,o=arguments.length,l=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(l=(o<3?i(l):o>3?i(t,n,l):i(t,n))||l);return o>3&&l&&Object.defineProperty(t,n,l),l},c=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},a=function(){function e(){var e=this;this.runningInstances=[],this.onInterrupted={report:function(t,n){if(n.interruptible){var r=!0;"keyup"===t.type?-1===o._interruptKeys.indexOf(t.keyCode)&&(r=!1):"mousedown"===t.type&&(n.scrollingViews.some(function(e){return e.contains(t.target)})||(r=!1)),r&&e.stopAll(n.namespace)}}},n.instanceCounter>0&&(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.warn("An instance of PageScrollService already exists, usually including one provider should be enough, so double check."),n.instanceCounter++}var n;return n=e,e.prototype.stopInternal=function(e,t){var n=this.runningInstances.indexOf(t);return n>=0&&this.runningInstances.splice(n,1),t.interruptListenersAttached&&t.detachInterruptListeners(),!!t.timer&&(clearInterval(t.timer),t.timer=void 0,t.fireEvent(!e),!0)},e.prototype.start=function(e){var n=this;if(this.stopAll(e.namespace),null!==e.scrollingViews&&0!==e.scrollingViews.length){var r=!1;e.startScrollPosition=0,e.scrollingViews.forEach(function(t){if(!l.isUndefinedOrNull(t)){var n=e.getScrollPropertyValue(t);!r&&n&&(e.startScrollPosition=n,r=!0)}});var i=e.getCurrentOffset(),s=e.extractScrollTargetPosition();if(e.targetScrollPosition=Math.round((e.verticalScrolling?s.top:s.left)-i),e.distanceToScroll=e.targetScrollPosition-e.startScrollPosition,isNaN(e.distanceToScroll))return(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.log("Scrolling not possible, as we can't find the specified target"),void e.fireEvent(!1);var c=Math.abs(e.distanceToScroll)<o._minScrollDistance;e.executionDuration=e.duration,!l.isUndefinedOrNull(e.speed)&&l.isUndefinedOrNull(e.duration)&&(e.executionDuration=Math.abs(e.distanceToScroll)/e.speed*1e3);var a=e.executionDuration<=o._interval;if(c||a)return(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&(c?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")),e.setScrollPosition(e.targetScrollPosition),void e.fireEvent(!0);(e.interruptible||l.isUndefinedOrNull(e.interruptible)&&o.defaultInterruptible)&&e.attachInterruptListeners(this.onInterrupted),e.startTime=(new Date).getTime(),e.endTime=e.startTime+e.executionDuration,e.timer=setInterval(function(e){var t,r=(new Date).getTime(),i=!1;e.endTime<=r?(t=e.targetScrollPosition,i=!0):t=Math.round(e.easingLogic.ease(r-e.startTime,e.startScrollPosition,e.distanceToScroll,e.executionDuration)),e.setScrollPosition(t)||(i=!0),i&&n.stopInternal(!1,e)},o._interval,e),this.runningInstances.push(e)}else(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.warn("No scrollingViews specified, this ngx-page-scroll does not know which DOM elements to scroll")},e.prototype.stopAll=function(e){if(this.runningInstances.length>0){for(var t=!1,n=0;n<this.runningInstances.length;++n){var r=this.runningInstances[n];(l.isUndefinedOrNull(e)||0===e.length||r.namespace===e)&&(t=!0,this.stopInternal(!0,r),n--)}return t}return!1},e.prototype.stop=function(e){return this.stopInternal(!0,e)},e.instanceCounter=0,e=n=s([t.Injectable(),c("design:paramtypes",[])],e)}();function u(e){return e||new a}var p={provide:a,deps:[[new t.Optional,new t.SkipSelf,a]],useFactory:u},f=function(){function e(e,n){this._namespace=o._defaultNamespace,this._verticalScrolling=o.defaultIsVerticalScrolling,this._offset=o.defaultScrollOffset,this._duration=o.defaultDuration,this._easingLogic=o.defaultEasingLogic,this._interruptible=o.defaultInterruptible,this._advancedInlineOffsetCalculation=o.defaultAdvancedInlineOffsetCalculation,this._pageScrollFinish=new t.EventEmitter,this._startScrollPosition=0,this._interruptListenersAttached=!1,this._timer=null,this._namespace=e,this.document=n}return e.simpleInstance=function(t,n,r){return e.newInstance({document:t,scrollTarget:n,namespace:r})},e.newInstance=function(t){(l.isUndefinedOrNull(t.namespace)||t.namespace.length<=0)&&(t.namespace=o._defaultNamespace);var n=new e(t.namespace,document);return l.isUndefinedOrNull(t.scrollingViews)||0===t.scrollingViews.length?(n._isInlineScrolling=!1,n._scrollingViews=[document.documentElement,document.body,document.body.parentNode]):(n._isInlineScrolling=!0,n._scrollingViews=t.scrollingViews),n._scrollTarget=t.scrollTarget,l.isUndefinedOrNull(t.verticalScrolling)||(n._verticalScrolling=t.verticalScrolling),l.isUndefinedOrNull(t.pageScrollOffset)||(n._offset=t.pageScrollOffset),l.isUndefinedOrNull(t.pageScrollEasingLogic)||(n._easingLogic=t.pageScrollEasingLogic),l.isUndefinedOrNull(t.pageScrollDuration)&&!l.isUndefinedOrNull(t.pageScrollSpeed)?(n._speed=t.pageScrollSpeed,n._duration=void 0):l.isUndefinedOrNull(t.pageScrollDuration)||(n._duration=t.pageScrollDuration),l.isUndefinedOrNull(t.pageScrollFinishListener)||(n._pageScrollFinish=t.pageScrollFinishListener),n._interruptible=t.pageScrollInterruptible||l.isUndefinedOrNull(t.pageScrollInterruptible)&&o.defaultInterruptible,n._advancedInlineOffsetCalculation=t.advancedInlineOffsetCalculation||l.isUndefinedOrNull(t.advancedInlineOffsetCalculation)&&o.defaultAdvancedInlineOffsetCalculation,n},e.prototype.getScrollPropertyValue=function(e){return this.verticalScrolling?e.scrollTop:e.scrollLeft},e.prototype.extractScrollTargetPosition=function(){var e;if("string"==typeof this._scrollTarget){var n=this._scrollTarget;e=null!==n.match(/^#[^\s]+$/g)?this.document.getElementById(n.substr(1)):this.document.querySelector(n)}else e=this._scrollTarget;if(null===e||void 0===e)return{top:NaN,left:NaN};if(this._isInlineScrolling){var r={top:e.offsetTop,left:e.offsetLeft};if(this._advancedInlineOffsetCalculation&&1===this.scrollingViews.length){for(var i={top:0,left:0},s=e.ownerDocument.defaultView,c=!1,a=e.parentElement;!c&&!l.isUndefinedOrNull(a);)"relative"===s.getComputedStyle(a).getPropertyValue("position")&&(i.top+=a.offsetTop,i.left+=a.offsetLeft),c=(a=a.parentElement)===this.scrollingViews[0];c?(r.top+=i.top,r.left+=i.left):(o._logLevel>=2||o._logLevel>=1&&t.isDevMode())&&console.warn("Unable to find nested scrolling targets parent!")}return r}return l.extractElementPosition(this.document,e)},e.prototype.getCurrentOffset=function(){return this._offset},e.prototype.setScrollPosition=function(e){var n=this;return o._logLevel>=5&&t.isDevMode()&&console.warn("Scroll Position: "+e),this.scrollingViews.reduce(function(t,r){var i=n.getScrollPropertyValue(r);if(r&&!l.isUndefinedOrNull(i)){var s=Math.abs(i-e),c=s<o._minScrollDistance;if(n.verticalScrolling?r.scrollTop=e:r.scrollLeft=e,c||s>Math.abs(n.getScrollPropertyValue(r)-e))return!0}return t},!1)},e.prototype.fireEvent=function(e){this._pageScrollFinish&&this._pageScrollFinish.emit(e)},e.prototype.attachInterruptListeners=function(e){var t=this;this._interruptListenersAttached&&this.detachInterruptListeners(),this._interruptListener=function(n){e.report(n,t)},o._interruptEvents.forEach(function(e){return t.document.body.addEventListener(e,t._interruptListener)}),this._interruptListenersAttached=!0},e.prototype.detachInterruptListeners=function(){var e=this;o._interruptEvents.forEach(function(t){return e.document.body.removeEventListener(t,e._interruptListener)}),this._interruptListenersAttached=!1},Object.defineProperty(e.prototype,"namespace",{get:function(){return this._namespace},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollTarget",{get:function(){return this._scrollTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"verticalScrolling",{get:function(){return this._verticalScrolling},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scrollingViews",{get:function(){return this._scrollingViews},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startScrollPosition",{get:function(){return this._startScrollPosition},set:function(e){this._startScrollPosition=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetScrollPosition",{get:function(){return this._targetScrollPosition},set:function(e){this._targetScrollPosition=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distanceToScroll",{get:function(){return this._distanceToScroll},set:function(e){this._distanceToScroll=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"executionDuration",{get:function(){return this._executionDuration},set:function(e){this._executionDuration=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speed",{get:function(){return this._speed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"easingLogic",{get:function(){return this._easingLogic},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interruptible",{get:function(){return this._interruptible},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startTime",{get:function(){return this._startTime},set:function(e){this._startTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endTime",{get:function(){return this._endTime},set:function(e){this._endTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"timer",{get:function(){return this._timer},set:function(e){this._timer=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interruptListenersAttached",{get:function(){return this._interruptListenersAttached},enumerable:!0,configurable:!0}),e}(),g=function(e,t,n,r){var i,o=arguments.length,l=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(l=(o<3?i(l):o>3?i(t,n,l):i(t,n))||l);return o>3&&l&&Object.defineProperty(t,n,l),l},d=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},h=function(e,t){return function(n,r){t(n,r,e)}},S=function(){function e(e,n,r){this.pageScrollService=e,this.router=n,this.pageScrollTarget=null,this.pageScrollHorizontal=null,this.pageScrollOffset=null,this.pageScrollDuration=null,this.pageScrollSpeed=null,this.pageScrollEasing=null,this.pageScrollAdjustHash=!1,this.pageScroll=null,this.pageScrollFinish=new t.EventEmitter,this.document=r}return e.prototype.ngOnChanges=function(e){this.pageScrollInstance=void 0},e.prototype.ngOnDestroy=function(){this.pageScrollInstance&&this.pageScrollService.stop(this.pageScrollInstance)},e.prototype.generatePageScrollInstance=function(){return l.isUndefinedOrNull(this.pageScrollInstance)&&(this.pageScrollInstance=f.newInstance({document:this.document,scrollTarget:this.pageScrollTarget||this.href,scrollingViews:null,namespace:this.pageScroll,verticalScrolling:!this.pageScrollHorizontal,pageScrollOffset:this.pageScrollOffset,pageScrollInterruptible:this.pageScrollInterruptible,pageScrollEasingLogic:this.pageScrollEasing,pageScrollDuration:this.pageScrollDuration,pageScrollSpeed:this.pageScrollSpeed,pageScrollFinishListener:this.pageScrollFinish})),this.pageScrollInstance},e.prototype.pushRouterState=function(){this.pageScrollAdjustHash&&"string"==typeof this.pageScrollInstance.scrollTarget&&"#"===this.pageScrollInstance.scrollTarget.substr(0,1)&&this.router.navigate([],{fragment:this.pageScrollInstance.scrollTarget.substr(1),preserveQueryParams:!0})},e.prototype.scroll=function(){var e=this.generatePageScrollInstance();this.pushRouterState(),this.pageScrollService.start(e)},e.prototype.handleClick=function(e){var t=this;if(this.routerLink&&null!==this.router&&void 0!==this.router){var r=void 0;if(r="string"==typeof this.routerLink?this.router.parseUrl(this.routerLink):this.router.createUrlTree(this.routerLink),!this.router.isActive(r,!0)){var i=this.router.events.subscribe(function(e){e instanceof n.NavigationEnd?(i.unsubscribe(),setTimeout(function(){t.scroll()},0)):(e instanceof n.NavigationError||e instanceof n.NavigationCancel)&&i.unsubscribe()});return!1}}return this.scroll(),!1},g([t.Input(),d("design:type",Object)],e.prototype,"routerLink",void 0),g([t.Input(),d("design:type",String)],e.prototype,"href",void 0),g([t.Input(),d("design:type",String)],e.prototype,"pageScrollTarget",void 0),g([t.Input(),d("design:type",Boolean)],e.prototype,"pageScrollHorizontal",void 0),g([t.Input(),d("design:type",Number)],e.prototype,"pageScrollOffset",void 0),g([t.Input(),d("design:type",Number)],e.prototype,"pageScrollDuration",void 0),g([t.Input(),d("design:type",Number)],e.prototype,"pageScrollSpeed",void 0),g([t.Input(),d("design:type",i)],e.prototype,"pageScrollEasing",void 0),g([t.Input(),d("design:type",Boolean)],e.prototype,"pageScrollInterruptible",void 0),g([t.Input(),d("design:type",Object)],e.prototype,"pageScrollAdjustHash",void 0),g([t.Input(),d("design:type",String)],e.prototype,"pageScroll",void 0),g([t.Output(),d("design:type",t.EventEmitter)],e.prototype,"pageScrollFinish",void 0),e=g([t.Directive({selector:"[pageScroll]",host:{"(click)":"handleClick($event)"}}),h(1,t.Optional()),h(2,t.Inject(r.DOCUMENT)),d("design:paramtypes",[a,n.Router,Object])],e)}(),v=function(e,t,n,r){var i,o=arguments.length,l=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(l=(o<3?i(l):o>3?i(t,n,l):i(t,n))||l);return o>3&&l&&Object.defineProperty(t,n,l),l},y=function(){function e(){}return e=v([t.NgModule({imports:[r.CommonModule],declarations:[S],exports:[S],providers:[p]})],e)}();e.PageScroll=S,e.PageScrollService=a,e.NgxPageScrollServiceProviderFactory=u,e.NgxPageScrollServiceProvider=p,e.EasingLogic=i,e.PageScrollConfig=o,e.PageScrollInstance=f,e.PageScrollUtilService=l,e.NgxPageScrollModule=y,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -0,1 +1,7 @@ | ||
## 5.0.1 (2018-11-30) | ||
### Other | ||
- Add angular 7 to supported version range (#329) | ||
## 5.0.0 (2018-05-12) | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "ngx-page-scroll", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Animated scrolling functionality for angular written in pure typescript", | ||
@@ -17,3 +17,3 @@ "scripts": { | ||
"lint:test": "tslint ./test/**/*.ts -t verbose --exclude ./test/**/*.d.ts", | ||
"prepublish": "npm run compile && npm run bundle:create", | ||
"prepare": "npm run compile && npm run bundle:create", | ||
"pretest": "npm run compile:tsc", | ||
@@ -50,22 +50,22 @@ "rollup": "rollup -c rollup.conf.js", | ||
"peerDependencies": { | ||
"@angular/core": ">=6.0.0 <7.0.0", | ||
"@angular/common": ">=6.0.0 <7.0.0", | ||
"@angular/platform-browser": ">=6.0.0 <7.0.0", | ||
"@angular/router": ">=6.0.0 <7.0.0" | ||
"@angular/core": ">=6.0.0 <8.0.0", | ||
"@angular/common": ">=6.0.0 <8.0.0", | ||
"@angular/platform-browser": ">=6.0.0 <8.0.0", | ||
"@angular/router": ">=6.0.0 <8.0.0" | ||
}, | ||
"devDependencies": { | ||
"@angular/animations": "^6.0.1", | ||
"@angular/common": "^6.0.1", | ||
"@angular/compiler": "^6.0.1", | ||
"@angular/compiler-cli": "^6.0.1", | ||
"@angular/core": "^6.0.1", | ||
"@angular/platform-browser": "^6.0.1", | ||
"@angular/platform-browser-dynamic": "^6.0.1", | ||
"@angular/platform-server": "^6.0.1", | ||
"@angular/router": "^6.0.1", | ||
"@angular/animations": "^7.1.1", | ||
"@angular/common": "^7.1.1", | ||
"@angular/compiler": "^7.1.1", | ||
"@angular/compiler-cli": "^7.1.1", | ||
"@angular/core": "^7.1.1", | ||
"@angular/platform-browser": "^7.1.1", | ||
"@angular/platform-browser-dynamic": "^7.1.1", | ||
"@angular/platform-server": "^7.1.1", | ||
"@angular/router": "^7.1.1", | ||
"@types/jasmine": "^2.8.7", | ||
"codelyzer": "~4.3.0", | ||
"codelyzer": "~4.5.0", | ||
"jasmine-core": "~3.1.0", | ||
"jasmine-spec-reporter": "~4.2.1", | ||
"protractor": "~5.3.2", | ||
"protractor": "~5.4.1", | ||
"rimraf": "^2.6.2", | ||
@@ -76,5 +76,5 @@ "rollup": "~0.58.2", | ||
"tslint": "^5.10.0", | ||
"typescript": "~2.7.2", | ||
"typescript": "~3.1.6", | ||
"zone.js": "~0.8.26" | ||
} | ||
} |
@@ -103,3 +103,3 @@ # ngx-page-scroll [![npm version](https://img.shields.io/npm/v/ngx-page-scroll.svg?style=flat)](https://www.npmjs.com/package/ngx-page-scroll) [![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) | ||
the same page (e.g. `#theId`). The `onClick` event will be interrupted and the scroll animation starts. | ||
Alternatively you may set the optional `pageScrolllTarget` property to a valid css selector to specify the | ||
Alternatively you may set the optional `pageScrollTarget` property to a valid css selector to specify the | ||
target element to scroll to. | ||
@@ -106,0 +106,0 @@ |
@@ -12,5 +12,3 @@ var EasingLogic = /** @class */ (function () { | ||
// Getter and setter to avoid auto completion to suggest calling the method | ||
get: | ||
// Getter and setter to avoid auto completion to suggest calling the method | ||
function () { | ||
get: function () { | ||
return PageScrollConfig._easingLogic; | ||
@@ -25,73 +23,73 @@ }, | ||
/** | ||
* The number of milliseconds to wait till updating the scroll position again. | ||
* Small amounts may produce smoother animations but require more processing power. | ||
* @type {number} | ||
*/ | ||
* The number of milliseconds to wait till updating the scroll position again. | ||
* Small amounts may produce smoother animations but require more processing power. | ||
* @type {number} | ||
*/ | ||
PageScrollConfig._interval = 10; | ||
/** | ||
* The amount of pixels that need to be between the current scrollTop/scrollLeft position | ||
* and the target position the cause a scroll animation. In case distance is below | ||
* this threshold, an immediate jump will be performed. | ||
* Due to dpi or rounding irregularities in browsers floating point numbers for scrollTop/scrollLeft values | ||
* are possible, making a === comparison of current scrollTop or scrollLeft and target scrollPosition error-prone. | ||
* @type {number} | ||
*/ | ||
* The amount of pixels that need to be between the current scrollTop/scrollLeft position | ||
* and the target position the cause a scroll animation. In case distance is below | ||
* this threshold, an immediate jump will be performed. | ||
* Due to dpi or rounding irregularities in browsers floating point numbers for scrollTop/scrollLeft values | ||
* are possible, making a === comparison of current scrollTop or scrollLeft and target scrollPosition error-prone. | ||
* @type {number} | ||
*/ | ||
PageScrollConfig._minScrollDistance = 2; | ||
/** | ||
* Name of the default namespace. | ||
* @type {string} | ||
*/ | ||
* Name of the default namespace. | ||
* @type {string} | ||
*/ | ||
PageScrollConfig._defaultNamespace = 'default'; | ||
/** | ||
* Whether by default the scrolling should happen in vertical direction (by manipulating the scrollTop property) | ||
* (= true; default) or in horizontal direction (by manipulating the scrollLeft property) (= false | ||
* @type {boolean} | ||
*/ | ||
* Whether by default the scrolling should happen in vertical direction (by manipulating the scrollTop property) | ||
* (= true; default) or in horizontal direction (by manipulating the scrollLeft property) (= false | ||
* @type {boolean} | ||
*/ | ||
PageScrollConfig.defaultIsVerticalScrolling = true; | ||
/** | ||
* How many console logs should be emitted. Also influenced by angular mode (dev or prod mode) | ||
* 0: No logs, neither in dev nor in prod mode | ||
* 1: Animation errors in dev mode, no logs in prod mode | ||
* 2: Animation errors in dev and prod mode | ||
* 5: Animation errors in dev and all scroll position values that get set; animation errors in prod mode | ||
* @type {number} | ||
*/ | ||
* How many console logs should be emitted. Also influenced by angular mode (dev or prod mode) | ||
* 0: No logs, neither in dev nor in prod mode | ||
* 1: Animation errors in dev mode, no logs in prod mode | ||
* 2: Animation errors in dev and prod mode | ||
* 5: Animation errors in dev and all scroll position values that get set; animation errors in prod mode | ||
* @type {number} | ||
*/ | ||
PageScrollConfig._logLevel = 1; | ||
/** | ||
* The duration how long a scrollTo animation should last by default. | ||
* May be overridden using the page-scroll-duration attribute on a single ngxPageScroll instance. | ||
* @type {number} | ||
*/ | ||
* The duration how long a scrollTo animation should last by default. | ||
* May be overridden using the page-scroll-duration attribute on a single ngxPageScroll instance. | ||
* @type {number} | ||
*/ | ||
PageScrollConfig.defaultDuration = 1250; | ||
/** | ||
* The distance in pixels above scroll target where the animation should stop. Setting a positive number results in | ||
* the scroll target being more in the middle of the screen, negative numbers will produce scrolling "too far" | ||
* @type {number} | ||
*/ | ||
* The distance in pixels above scroll target where the animation should stop. Setting a positive number results in | ||
* the scroll target being more in the middle of the screen, negative numbers will produce scrolling "too far" | ||
* @type {number} | ||
*/ | ||
PageScrollConfig.defaultScrollOffset = 0; | ||
/** | ||
* Whether by default for inline scroll animations the advanced offset calculation should take place (true) or | ||
* not (false). Default is false. | ||
* The advanced offset calculation will traverse the DOM tree upwards, starting at the scrollTarget, until it finds | ||
* the scrollingView container element. Along the way the offset positions of the relative positioned | ||
* (position: relative) elements will be taken into account for calculating the target elements position. | ||
* @type {boolean} | ||
*/ | ||
* Whether by default for inline scroll animations the advanced offset calculation should take place (true) or | ||
* not (false). Default is false. | ||
* The advanced offset calculation will traverse the DOM tree upwards, starting at the scrollTarget, until it finds | ||
* the scrollingView container element. Along the way the offset positions of the relative positioned | ||
* (position: relative) elements will be taken into account for calculating the target elements position. | ||
* @type {boolean} | ||
*/ | ||
PageScrollConfig.defaultAdvancedInlineOffsetCalculation = false; | ||
/** | ||
* The events that are listened to on the body to decide whether a scroll animation has been interfered/interrupted by the user | ||
* @type {string[]} | ||
*/ | ||
* The events that are listened to on the body to decide whether a scroll animation has been interfered/interrupted by the user | ||
* @type {string[]} | ||
*/ | ||
PageScrollConfig._interruptEvents = ['mousedown', 'wheel', 'DOMMouseScroll', 'mousewheel', 'keyup', 'touchmove']; | ||
/** | ||
* The keys that are considered to interrupt a scroll animation (mainly the arrow keys). All other key presses will not stop the | ||
* scroll animation. | ||
* @type {number[]} | ||
*/ | ||
* The keys that are considered to interrupt a scroll animation (mainly the arrow keys). All other key presses will not stop the | ||
* scroll animation. | ||
* @type {number[]} | ||
*/ | ||
PageScrollConfig._interruptKeys = [33, 34, 35, 36, 38, 40]; | ||
/** | ||
* Whether a scroll animation should be interruptible by user interaction (true) or not (false). If the user performs an | ||
* interrupting event while a scroll animation takes place, the scroll animation stops. | ||
* @type {boolean} | ||
*/ | ||
* Whether a scroll animation should be interruptible by user interaction (true) or not (false). If the user performs an | ||
* interrupting event while a scroll animation takes place, the scroll animation stops. | ||
* @type {boolean} | ||
*/ | ||
PageScrollConfig.defaultInterruptible = true; | ||
@@ -98,0 +96,0 @@ PageScrollConfig._easingLogic = { |
@@ -7,6 +7,3 @@ import { EventEmitter, isDevMode } from '@angular/core'; | ||
*/ | ||
var /** | ||
* Represents a scrolling action | ||
*/ | ||
PageScrollInstance = /** @class */ (function () { | ||
var PageScrollInstance = /** @class */ (function () { | ||
/** | ||
@@ -22,4 +19,4 @@ * Private constructor, requires the properties assumed to be the bare minimum. | ||
/** | ||
* These properties will be set during instance construction and default to their defaults from PageScrollConfig | ||
*/ | ||
* These properties will be set during instance construction and default to their defaults from PageScrollConfig | ||
*/ | ||
/* A namespace to "group" scroll animations together and stopping some does not stop others */ | ||
@@ -42,4 +39,4 @@ this._namespace = PageScrollConfig._defaultNamespace; | ||
/** | ||
* These properties will be set/manipulated if the scroll animation starts | ||
*/ | ||
* These properties will be set/manipulated if the scroll animation starts | ||
*/ | ||
/* The initial value of the scrollTop or scrollLeft position when the animation starts */ | ||
@@ -50,3 +47,3 @@ this._startScrollPosition = 0; | ||
/* References to the timer instance that is used to perform the scroll animation to be | ||
able to clear it on animation end*/ | ||
able to clear it on animation end*/ | ||
this._timer = null; | ||
@@ -59,9 +56,3 @@ this._namespace = namespace; | ||
*/ | ||
/* | ||
* Factory methods for instance creation | ||
*/ | ||
PageScrollInstance.simpleInstance = /* | ||
* Factory methods for instance creation | ||
*/ | ||
function (document, scrollTarget, namespace) { | ||
PageScrollInstance.simpleInstance = function (document, scrollTarget, namespace) { | ||
return PageScrollInstance.newInstance({ | ||
@@ -128,19 +119,3 @@ document: document, | ||
*/ | ||
/** | ||
* Extract the exact location of the scrollTarget element. | ||
* | ||
* Extract the scrollTarget HTMLElement from the given PageScrollTarget object. The latter one may be | ||
* a string like "#heading2", then this method returns the corresponding DOM element for that id. | ||
* | ||
* @returns {HTMLElement} | ||
*/ | ||
PageScrollInstance.prototype.extractScrollTargetPosition = /** | ||
* Extract the exact location of the scrollTarget element. | ||
* | ||
* Extract the scrollTarget HTMLElement from the given PageScrollTarget object. The latter one may be | ||
* a string like "#heading2", then this method returns the corresponding DOM element for that id. | ||
* | ||
* @returns {HTMLElement} | ||
*/ | ||
function () { | ||
PageScrollInstance.prototype.extractScrollTargetPosition = function () { | ||
var scrollTargetElement; | ||
@@ -180,3 +155,2 @@ if (typeof this._scrollTarget === 'string') { | ||
// Next iteration | ||
// Next iteration | ||
parent_1 = parent_1.parentElement; | ||
@@ -207,17 +181,3 @@ parentFound = parent_1 === this.scrollingViews[0]; | ||
*/ | ||
/** | ||
* Get the top offset of the scroll animation. | ||
* This automatically takes the offset location of the scrolling container/scrolling view | ||
* into account (for nested/inline scrolling). | ||
* | ||
* @returns {number} | ||
*/ | ||
PageScrollInstance.prototype.getCurrentOffset = /** | ||
* Get the top offset of the scroll animation. | ||
* This automatically takes the offset location of the scrolling container/scrolling view | ||
* into account (for nested/inline scrolling). | ||
* | ||
* @returns {number} | ||
*/ | ||
function () { | ||
PageScrollInstance.prototype.getCurrentOffset = function () { | ||
return this._offset; | ||
@@ -232,17 +192,3 @@ }; | ||
*/ | ||
/** | ||
* Sets the "scrollTop" or "scrollLeft" property for all scrollingViews to the provided value | ||
* @param position | ||
* @return true if at least for one ScrollTopSource the scrollTop/scrollLeft value could be set and it kept the new value. | ||
* false if it failed for all ScrollingViews, meaning that we should stop the animation | ||
* (probably because we're at the end of the scrolling region) | ||
*/ | ||
PageScrollInstance.prototype.setScrollPosition = /** | ||
* Sets the "scrollTop" or "scrollLeft" property for all scrollingViews to the provided value | ||
* @param position | ||
* @return true if at least for one ScrollTopSource the scrollTop/scrollLeft value could be set and it kept the new value. | ||
* false if it failed for all ScrollingViews, meaning that we should stop the animation | ||
* (probably because we're at the end of the scrolling region) | ||
*/ | ||
function (position) { | ||
PageScrollInstance.prototype.setScrollPosition = function (position) { | ||
var _this = this; | ||
@@ -284,11 +230,3 @@ if (PageScrollConfig._logLevel >= 5 && isDevMode()) { | ||
*/ | ||
/** | ||
* Trigger firing a animation finish event | ||
* @param value Whether the animation finished at the target (true) or got interrupted (false) | ||
*/ | ||
PageScrollInstance.prototype.fireEvent = /** | ||
* Trigger firing a animation finish event | ||
* @param value Whether the animation finished at the target (true) or got interrupted (false) | ||
*/ | ||
function (value) { | ||
PageScrollInstance.prototype.fireEvent = function (value) { | ||
if (this._pageScrollFinish) { | ||
@@ -306,19 +244,3 @@ this._pageScrollFinish.emit(value); | ||
*/ | ||
/** | ||
* Attach the interrupt listeners to the PageScrollInstance body. The given interruptReporter | ||
* will be called if any of the attached events is fired. | ||
* | ||
* Possibly attached interruptListeners are automatically removed from the body before the new one will be attached. | ||
* | ||
* @param interruptReporter | ||
*/ | ||
PageScrollInstance.prototype.attachInterruptListeners = /** | ||
* Attach the interrupt listeners to the PageScrollInstance body. The given interruptReporter | ||
* will be called if any of the attached events is fired. | ||
* | ||
* Possibly attached interruptListeners are automatically removed from the body before the new one will be attached. | ||
* | ||
* @param interruptReporter | ||
*/ | ||
function (interruptReporter) { | ||
PageScrollInstance.prototype.attachInterruptListeners = function (interruptReporter) { | ||
var _this = this; | ||
@@ -339,11 +261,3 @@ if (this._interruptListenersAttached) { | ||
*/ | ||
/** | ||
* Remove event listeners from the body and stop listening for events that might be treated as "animation | ||
* interrupt" events. | ||
*/ | ||
PageScrollInstance.prototype.detachInterruptListeners = /** | ||
* Remove event listeners from the body and stop listening for events that might be treated as "animation | ||
* interrupt" events. | ||
*/ | ||
function () { | ||
PageScrollInstance.prototype.detachInterruptListeners = function () { | ||
var _this = this; | ||
@@ -488,5 +402,2 @@ PageScrollConfig._interruptEvents.forEach(function (event) { return _this.document.body.removeEventListener(event, _this._interruptListener); }); | ||
}()); | ||
/** | ||
* Represents a scrolling action | ||
*/ | ||
export { PageScrollInstance }; |
@@ -9,13 +9,3 @@ var PageScrollUtilService = /** @class */ (function () { | ||
*/ | ||
/** | ||
* Util method to check whether a given variable is either undefined or null | ||
* @param variable | ||
* @returns {boolean} true the variable is undefined or null | ||
*/ | ||
PageScrollUtilService.isUndefinedOrNull = /** | ||
* Util method to check whether a given variable is either undefined or null | ||
* @param variable | ||
* @returns {boolean} true the variable is undefined or null | ||
*/ | ||
function (variable) { | ||
PageScrollUtilService.isUndefinedOrNull = function (variable) { | ||
return (typeof variable === 'undefined') || variable === undefined || variable === null; | ||
@@ -22,0 +12,0 @@ }; |
@@ -25,6 +25,6 @@ import { EventEmitter, OnDestroy, OnChanges, SimpleChanges } from '@angular/core'; | ||
ngOnDestroy(): void; | ||
private generatePageScrollInstance(); | ||
private pushRouterState(); | ||
private scroll(); | ||
private generatePageScrollInstance; | ||
private pushRouterState; | ||
private scroll; | ||
handleClick(clickEvent: Event): boolean; | ||
} |
@@ -0,1 +1,13 @@ | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
import { Directive, Input, Output, EventEmitter, Inject, Optional } from '@angular/core'; | ||
@@ -68,3 +80,2 @@ import { Router, NavigationEnd, NavigationError, NavigationCancel } from '@angular/router'; | ||
var _this = this; | ||
// tslint:disable-line:no-unused-variable | ||
if (this.routerLink && this.router !== null && this.router !== undefined) { | ||
@@ -100,33 +111,62 @@ var urlTree = void 0; | ||
}; | ||
PageScroll.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[pageScroll]', | ||
host: { | ||
// tslint:disable-line:use-host-property-decorator | ||
'(click)': 'handleClick($event)', | ||
} | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
PageScroll.ctorParameters = function () { return [ | ||
{ type: PageScrollService, }, | ||
{ type: Router, decorators: [{ type: Optional },] }, | ||
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] },] }, | ||
]; }; | ||
PageScroll.propDecorators = { | ||
"routerLink": [{ type: Input },], | ||
"href": [{ type: Input },], | ||
"pageScrollTarget": [{ type: Input },], | ||
"pageScrollHorizontal": [{ type: Input },], | ||
"pageScrollOffset": [{ type: Input },], | ||
"pageScrollDuration": [{ type: Input },], | ||
"pageScrollSpeed": [{ type: Input },], | ||
"pageScrollEasing": [{ type: Input },], | ||
"pageScrollInterruptible": [{ type: Input },], | ||
"pageScrollAdjustHash": [{ type: Input },], | ||
"pageScroll": [{ type: Input },], | ||
"pageScrollFinish": [{ type: Output },], | ||
}; | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Object) | ||
], PageScroll.prototype, "routerLink", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", String) | ||
], PageScroll.prototype, "href", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", String) | ||
], PageScroll.prototype, "pageScrollTarget", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Boolean) | ||
], PageScroll.prototype, "pageScrollHorizontal", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Number) | ||
], PageScroll.prototype, "pageScrollOffset", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Number) | ||
], PageScroll.prototype, "pageScrollDuration", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Number) | ||
], PageScroll.prototype, "pageScrollSpeed", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", EasingLogic) | ||
], PageScroll.prototype, "pageScrollEasing", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Boolean) | ||
], PageScroll.prototype, "pageScrollInterruptible", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", Object) | ||
], PageScroll.prototype, "pageScrollAdjustHash", void 0); | ||
__decorate([ | ||
Input(), | ||
__metadata("design:type", String) | ||
], PageScroll.prototype, "pageScroll", void 0); | ||
__decorate([ | ||
Output(), | ||
__metadata("design:type", EventEmitter) | ||
], PageScroll.prototype, "pageScrollFinish", void 0); | ||
PageScroll = __decorate([ | ||
Directive({ | ||
selector: '[pageScroll]', | ||
host: { | ||
'(click)': 'handleClick($event)', | ||
} | ||
}), | ||
__param(1, Optional()), __param(2, Inject(DOCUMENT)), | ||
__metadata("design:paramtypes", [PageScrollService, Router, Object]) | ||
], PageScroll); | ||
return PageScroll; | ||
}()); | ||
export { PageScroll }; |
@@ -0,1 +1,7 @@ | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
import { CommonModule } from '@angular/common'; | ||
@@ -8,12 +14,12 @@ import { NgModule } from '@angular/core'; | ||
} | ||
NgxPageScrollModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
imports: [CommonModule], | ||
declarations: [PageScroll], | ||
exports: [PageScroll], | ||
providers: [NgxPageScrollServiceProvider] | ||
},] }, | ||
]; | ||
NgxPageScrollModule = __decorate([ | ||
NgModule({ | ||
imports: [CommonModule], | ||
declarations: [PageScroll], | ||
exports: [PageScroll], | ||
providers: [NgxPageScrollServiceProvider] | ||
}) | ||
], NgxPageScrollModule); | ||
return NgxPageScrollModule; | ||
}()); | ||
export { NgxPageScrollModule }; |
@@ -7,3 +7,3 @@ import { Optional } from '@angular/core'; | ||
private onInterrupted; | ||
private stopInternal(interrupted, pageScrollInstance); | ||
private stopInternal; | ||
/** | ||
@@ -10,0 +10,0 @@ * Start a scroll animation. All properties of the animation are stored in the given {@link PageScrollInstance} object. |
@@ -0,1 +1,10 @@ | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
import { Injectable, Optional, SkipSelf, isDevMode } from '@angular/core'; | ||
@@ -35,3 +44,3 @@ import { PageScrollConfig } from './ngx-page-scroll-config'; | ||
}; | ||
if (PageScrollService.instanceCounter > 0 && | ||
if (PageScrollService_1.instanceCounter > 0 && | ||
(PageScrollConfig._logLevel >= 2 || (PageScrollConfig._logLevel >= 1 && isDevMode()))) { | ||
@@ -41,4 +50,5 @@ console.warn('An instance of PageScrollService already exists, usually ' + | ||
} | ||
PageScrollService.instanceCounter++; | ||
PageScrollService_1.instanceCounter++; | ||
} | ||
PageScrollService_1 = PageScrollService; | ||
PageScrollService.prototype.stopInternal = function (interrupted, pageScrollInstance) { | ||
@@ -69,17 +79,3 @@ var index = this.runningInstances.indexOf(pageScrollInstance); | ||
*/ | ||
/** | ||
* Start a scroll animation. All properties of the animation are stored in the given {@link PageScrollInstance} object. | ||
* | ||
* This is the core functionality of the whole library. | ||
* | ||
* @param pageScrollInstance | ||
*/ | ||
PageScrollService.prototype.start = /** | ||
* Start a scroll animation. All properties of the animation are stored in the given {@link PageScrollInstance} object. | ||
* | ||
* This is the core functionality of the whole library. | ||
* | ||
* @param pageScrollInstance | ||
*/ | ||
function (pageScrollInstance) { | ||
PageScrollService.prototype.start = function (pageScrollInstance) { | ||
var _this = this; | ||
@@ -200,15 +196,3 @@ // Stop all possibly running scroll animations in the same namespace | ||
*/ | ||
/** | ||
* Stop all running scroll animations. Optionally limit to stop only the ones of specific namespace. | ||
* | ||
* @param namespace | ||
* @returns {boolean} | ||
*/ | ||
PageScrollService.prototype.stopAll = /** | ||
* Stop all running scroll animations. Optionally limit to stop only the ones of specific namespace. | ||
* | ||
* @param namespace | ||
* @returns {boolean} | ||
*/ | ||
function (namespace) { | ||
PageScrollService.prototype.stopAll = function (namespace) { | ||
if (this.runningInstances.length > 0) { | ||
@@ -233,8 +217,8 @@ var stoppedSome = false; | ||
}; | ||
var PageScrollService_1; | ||
PageScrollService.instanceCounter = 0; | ||
PageScrollService.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
PageScrollService.ctorParameters = function () { return []; }; | ||
PageScrollService = PageScrollService_1 = __decorate([ | ||
Injectable(), | ||
__metadata("design:paramtypes", []) | ||
], PageScrollService); | ||
return PageScrollService; | ||
@@ -241,0 +225,0 @@ }()); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160751
2351