ngx-page-scroll-core
Advanced tools
Comparing version 6.0.1 to 6.0.2
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) : | ||
typeof define === 'function' && define.amd ? define('ngx-page-scroll-core', ['exports', '@angular/core'], factory) : | ||
(global = global || self, factory(global['ngx-page-scroll-core'] = {}, global.ng.core)); | ||
}(this, function (exports, core) { 'use strict'; | ||
(factory((global['ngx-page-scroll-core'] = {}),global.ng.core)); | ||
}(this, (function (exports,i0) { 'use strict'; | ||
@@ -21,8 +21,9 @@ /*! ***************************************************************************** | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
var __assign = function () { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
@@ -41,6 +42,5 @@ return t; | ||
*/ | ||
var /** | ||
var /** | ||
* Represents a scrolling action | ||
*/ | ||
PageScrollInstance = /** @class */ (function () { | ||
*/ PageScrollInstance = /** @class */ (function () { | ||
/** | ||
@@ -87,33 +87,33 @@ * Private constructor, requires the properties assumed to be the bare minimum. | ||
*/ | ||
function (pageScrollOptions, scrollTargetElement) { | ||
/** @type {?} */ | ||
var body = pageScrollOptions.document.body; | ||
/** @type {?} */ | ||
var docEl = pageScrollOptions.document.documentElement; | ||
/** @type {?} */ | ||
var windowPageYOffset = pageScrollOptions.document.defaultView && | ||
pageScrollOptions.document.defaultView.pageYOffset || undefined; | ||
/** @type {?} */ | ||
var windowPageXOffset = pageScrollOptions.document.defaultView && | ||
pageScrollOptions.document.defaultView.pageXOffset || undefined; | ||
/** @type {?} */ | ||
var scrollTop = windowPageYOffset || docEl.scrollTop || body.scrollTop; | ||
/** @type {?} */ | ||
var scrollLeft = windowPageXOffset || docEl.scrollLeft || body.scrollLeft; | ||
/** @type {?} */ | ||
var clientTop = docEl.clientTop || body.clientTop || 0; | ||
/** @type {?} */ | ||
var clientLeft = docEl.clientLeft || body.clientLeft || 0; | ||
if (scrollTargetElement === undefined || scrollTargetElement === null) { | ||
// No element found, so return the current position to not cause any change in scroll position | ||
return { top: scrollTop, left: scrollLeft }; | ||
} | ||
/** @type {?} */ | ||
var box = scrollTargetElement.getBoundingClientRect(); | ||
/** @type {?} */ | ||
var top = box.top + scrollTop - clientTop; | ||
/** @type {?} */ | ||
var left = box.left + scrollLeft - clientLeft; | ||
return { top: Math.round(top), left: Math.round(left) }; | ||
}; | ||
function (pageScrollOptions, scrollTargetElement) { | ||
/** @type {?} */ | ||
var body = pageScrollOptions.document.body; | ||
/** @type {?} */ | ||
var docEl = pageScrollOptions.document.documentElement; | ||
/** @type {?} */ | ||
var windowPageYOffset = pageScrollOptions.document.defaultView && | ||
pageScrollOptions.document.defaultView.pageYOffset || undefined; | ||
/** @type {?} */ | ||
var windowPageXOffset = pageScrollOptions.document.defaultView && | ||
pageScrollOptions.document.defaultView.pageXOffset || undefined; | ||
/** @type {?} */ | ||
var scrollTop = windowPageYOffset || docEl.scrollTop || body.scrollTop; | ||
/** @type {?} */ | ||
var scrollLeft = windowPageXOffset || docEl.scrollLeft || body.scrollLeft; | ||
/** @type {?} */ | ||
var clientTop = docEl.clientTop || body.clientTop || 0; | ||
/** @type {?} */ | ||
var clientLeft = docEl.clientLeft || body.clientLeft || 0; | ||
if (scrollTargetElement === undefined || scrollTargetElement === null) { | ||
// No element found, so return the current position to not cause any change in scroll position | ||
return { top: scrollTop, left: scrollLeft }; | ||
} | ||
/** @type {?} */ | ||
var box = scrollTargetElement.getBoundingClientRect(); | ||
/** @type {?} */ | ||
var top = box.top + scrollTop - clientTop; | ||
/** @type {?} */ | ||
var left = box.left + scrollLeft - clientLeft; | ||
return { top: Math.round(top), left: Math.round(left) }; | ||
}; | ||
/** | ||
@@ -131,34 +131,34 @@ * @private | ||
*/ | ||
function (pageScrollOptions, scrollTargetElement) { | ||
/** @type {?} */ | ||
var position = { top: scrollTargetElement.offsetTop, left: scrollTargetElement.offsetLeft }; | ||
if (pageScrollOptions.advancedInlineOffsetCalculation && pageScrollOptions.scrollViews.length === 1) { | ||
function (pageScrollOptions, scrollTargetElement) { | ||
/** @type {?} */ | ||
var accumulatedParentsPos = { top: 0, left: 0 }; | ||
// not named window to make sure we're not getting the global window variable by accident | ||
/** @type {?} */ | ||
var theWindow = scrollTargetElement.ownerDocument.defaultView; | ||
/** @type {?} */ | ||
var parentFound = false; | ||
// Start parent is the immediate parent | ||
/** @type {?} */ | ||
var parent_1 = scrollTargetElement.parentElement; | ||
// Iterate upwards all parents | ||
while (!parentFound && parent_1 !== undefined && parent_1 !== null) { | ||
if (theWindow.getComputedStyle(parent_1).getPropertyValue('position') === 'relative') { | ||
accumulatedParentsPos.top += parent_1.offsetTop; | ||
accumulatedParentsPos.left += parent_1.offsetLeft; | ||
var position = { top: scrollTargetElement.offsetTop, left: scrollTargetElement.offsetLeft }; | ||
if (pageScrollOptions.advancedInlineOffsetCalculation && pageScrollOptions.scrollViews.length === 1) { | ||
/** @type {?} */ | ||
var accumulatedParentsPos = { top: 0, left: 0 }; | ||
// not named window to make sure we're not getting the global window variable by accident | ||
/** @type {?} */ | ||
var theWindow = scrollTargetElement.ownerDocument.defaultView; | ||
/** @type {?} */ | ||
var parentFound = false; | ||
// Start parent is the immediate parent | ||
/** @type {?} */ | ||
var parent_1 = scrollTargetElement.parentElement; | ||
// Iterate upwards all parents | ||
while (!parentFound && parent_1 !== undefined && parent_1 !== null) { | ||
if (theWindow.getComputedStyle(parent_1).getPropertyValue('position') === 'relative') { | ||
accumulatedParentsPos.top += parent_1.offsetTop; | ||
accumulatedParentsPos.left += parent_1.offsetLeft; | ||
} | ||
// Next iteration | ||
parent_1 = parent_1.parentElement; | ||
parentFound = parent_1 === pageScrollOptions.scrollViews[0]; | ||
} | ||
// Next iteration | ||
parent_1 = parent_1.parentElement; | ||
parentFound = parent_1 === pageScrollOptions.scrollViews[0]; | ||
if (parentFound) { | ||
// Only use the results if we found the parent, otherwise we accumulated too much anyway | ||
position.top += accumulatedParentsPos.top; | ||
position.left += accumulatedParentsPos.left; | ||
} | ||
} | ||
if (parentFound) { | ||
// Only use the results if we found the parent, otherwise we accumulated too much anyway | ||
position.top += accumulatedParentsPos.top; | ||
position.left += accumulatedParentsPos.left; | ||
} | ||
} | ||
return position; | ||
}; | ||
return position; | ||
}; | ||
/** | ||
@@ -172,8 +172,8 @@ * @param {?} scrollingView | ||
*/ | ||
function (scrollingView) { | ||
if (!this.pageScrollOptions.verticalScrolling) { | ||
return scrollingView.scrollLeft; | ||
} | ||
return scrollingView.scrollTop; | ||
}; | ||
function (scrollingView) { | ||
if (!this.pageScrollOptions.verticalScrolling) { | ||
return scrollingView.scrollLeft; | ||
} | ||
return scrollingView.scrollTop; | ||
}; | ||
/** | ||
@@ -202,14 +202,14 @@ * Extract the exact location of the scrollTarget element. | ||
*/ | ||
function () { | ||
/** @type {?} */ | ||
var scrollTargetElement = this.getScrollTargetElement(); | ||
if (scrollTargetElement === null || scrollTargetElement === undefined) { | ||
// Scroll target not found | ||
return { top: NaN, left: NaN }; | ||
} | ||
if (this.isInlineScrolling) { | ||
return PageScrollInstance.getInlineScrollingTargetPosition(this.pageScrollOptions, scrollTargetElement); | ||
} | ||
return PageScrollInstance.getScrollingTargetPosition(this.pageScrollOptions, scrollTargetElement); | ||
}; | ||
function () { | ||
/** @type {?} */ | ||
var scrollTargetElement = this.getScrollTargetElement(); | ||
if (scrollTargetElement === null || scrollTargetElement === undefined) { | ||
// Scroll target not found | ||
return { top: NaN, left: NaN }; | ||
} | ||
if (this.isInlineScrolling) { | ||
return PageScrollInstance.getInlineScrollingTargetPosition(this.pageScrollOptions, scrollTargetElement); | ||
} | ||
return PageScrollInstance.getScrollingTargetPosition(this.pageScrollOptions, scrollTargetElement); | ||
}; | ||
/** | ||
@@ -232,5 +232,5 @@ * Get the top offset of the scroll animation. | ||
*/ | ||
function () { | ||
return this.pageScrollOptions.scrollOffset; | ||
}; | ||
function () { | ||
return this.pageScrollOptions.scrollOffset; | ||
}; | ||
/** | ||
@@ -256,40 +256,39 @@ * Sets the "scrollTop" or "scrollLeft" property for all scrollViews to the provided value | ||
*/ | ||
function (position) { | ||
var _this = this; | ||
// Set the new scrollTop/scrollLeft to all scrollViews elements | ||
return this.pageScrollOptions.scrollViews.reduce((/** | ||
* @param {?} oneAlreadyWorked | ||
* @param {?} scrollingView | ||
* @return {?} | ||
*/ | ||
function (oneAlreadyWorked, scrollingView) { | ||
/** @type {?} */ | ||
var startScrollPropertyValue = _this.getScrollPropertyValue(scrollingView); | ||
if (scrollingView && startScrollPropertyValue !== undefined && startScrollPropertyValue !== null) { | ||
function (position) { | ||
var _this = this; | ||
// Set the new scrollTop/scrollLeft to all scrollViews elements | ||
return this.pageScrollOptions.scrollViews.reduce(( /** | ||
* @param {?} oneAlreadyWorked | ||
* @param {?} scrollingView | ||
* @return {?} | ||
*/function (oneAlreadyWorked, scrollingView) { | ||
/** @type {?} */ | ||
var scrollDistance = Math.abs(startScrollPropertyValue - position); | ||
// The movement we need to perform is less than 2px | ||
// This we consider a small movement which some browser may not perform when | ||
// changing the scrollTop/scrollLeft property | ||
// Thus in this cases we do not stop the scroll animation, although setting the | ||
// scrollTop/scrollLeft value "fails" | ||
/** @type {?} */ | ||
var isSmallMovement = scrollDistance < _this.pageScrollOptions._minScrollDistance; | ||
if (!_this.pageScrollOptions.verticalScrolling) { | ||
scrollingView.scrollLeft = position; | ||
var startScrollPropertyValue = _this.getScrollPropertyValue(scrollingView); | ||
if (scrollingView && startScrollPropertyValue !== undefined && startScrollPropertyValue !== null) { | ||
/** @type {?} */ | ||
var scrollDistance = Math.abs(startScrollPropertyValue - position); | ||
// The movement we need to perform is less than 2px | ||
// This we consider a small movement which some browser may not perform when | ||
// changing the scrollTop/scrollLeft property | ||
// Thus in this cases we do not stop the scroll animation, although setting the | ||
// scrollTop/scrollLeft value "fails" | ||
/** @type {?} */ | ||
var isSmallMovement = scrollDistance < _this.pageScrollOptions._minScrollDistance; | ||
if (!_this.pageScrollOptions.verticalScrolling) { | ||
scrollingView.scrollLeft = position; | ||
} | ||
else { | ||
scrollingView.scrollTop = position; | ||
} | ||
// Return true if setting the new scrollTop/scrollLeft value worked | ||
// We consider that it worked if the new scrollTop/scrollLeft value is closer to the | ||
// desired scrollTop/scrollLeft than before (it might not be exactly the value we | ||
// set due to dpi or rounding irregularities) | ||
if (isSmallMovement || scrollDistance > Math.abs(_this.getScrollPropertyValue(scrollingView) - position)) { | ||
return true; | ||
} | ||
} | ||
else { | ||
scrollingView.scrollTop = position; | ||
} | ||
// Return true if setting the new scrollTop/scrollLeft value worked | ||
// We consider that it worked if the new scrollTop/scrollLeft value is closer to the | ||
// desired scrollTop/scrollLeft than before (it might not be exactly the value we | ||
// set due to dpi or rounding irregularities) | ||
if (isSmallMovement || scrollDistance > Math.abs(_this.getScrollPropertyValue(scrollingView) - position)) { | ||
return true; | ||
} | ||
} | ||
return oneAlreadyWorked; | ||
}), false); | ||
}; | ||
return oneAlreadyWorked; | ||
}), false); | ||
}; | ||
/** | ||
@@ -309,7 +308,7 @@ * Trigger firing a animation finish event | ||
*/ | ||
function (value) { | ||
if (this.pageScrollOptions.scrollFinishListener) { | ||
this.pageScrollOptions.scrollFinishListener.emit(value); | ||
} | ||
}; | ||
function (value) { | ||
if (this.pageScrollOptions.scrollFinishListener) { | ||
this.pageScrollOptions.scrollFinishListener.emit(value); | ||
} | ||
}; | ||
/** | ||
@@ -337,22 +336,20 @@ * Attach the interrupt listeners to the PageScrollInstance body. The given interruptReporter | ||
*/ | ||
function (interruptReporter) { | ||
var _this = this; | ||
if (this.interruptListenersAttached) { | ||
// Detach possibly existing listeners first | ||
this.detachInterruptListeners(); | ||
} | ||
this.interruptListener = (/** | ||
* @param {?} event | ||
* @return {?} | ||
*/ | ||
function (event) { | ||
interruptReporter.report(event, _this); | ||
}); | ||
this.pageScrollOptions.interruptEvents.forEach((/** | ||
* @param {?} event | ||
* @return {?} | ||
*/ | ||
function (event) { return _this.pageScrollOptions.document.body.addEventListener(event, _this.interruptListener); })); | ||
this.interruptListenersAttached = true; | ||
}; | ||
function (interruptReporter) { | ||
var _this = this; | ||
if (this.interruptListenersAttached) { | ||
// Detach possibly existing listeners first | ||
this.detachInterruptListeners(); | ||
} | ||
this.interruptListener = ( /** | ||
* @param {?} event | ||
* @return {?} | ||
*/function (event) { | ||
interruptReporter.report(event, _this); | ||
}); | ||
this.pageScrollOptions.interruptEvents.forEach(( /** | ||
* @param {?} event | ||
* @return {?} | ||
*/function (event) { return _this.pageScrollOptions.document.body.addEventListener(event, _this.interruptListener); })); | ||
this.interruptListenersAttached = true; | ||
}; | ||
/** | ||
@@ -372,11 +369,10 @@ * Remove event listeners from the body and stop listening for events that might be treated as "animation | ||
*/ | ||
function () { | ||
var _this = this; | ||
this.pageScrollOptions.interruptEvents.forEach((/** | ||
* @param {?} event | ||
* @return {?} | ||
*/ | ||
function (event) { return _this.pageScrollOptions.document.body.removeEventListener(event, _this.interruptListener); })); | ||
this.interruptListenersAttached = false; | ||
}; | ||
function () { | ||
var _this = this; | ||
this.pageScrollOptions.interruptEvents.forEach(( /** | ||
* @param {?} event | ||
* @return {?} | ||
*/function (event) { return _this.pageScrollOptions.document.body.removeEventListener(event, _this.interruptListener); })); | ||
this.interruptListenersAttached = false; | ||
}; | ||
/** | ||
@@ -390,14 +386,14 @@ * @private | ||
*/ | ||
function () { | ||
if (typeof this.pageScrollOptions.scrollTarget === 'string') { | ||
/** @type {?} */ | ||
var targetSelector = (/** @type {?} */ (this.pageScrollOptions.scrollTarget)); | ||
if (targetSelector.match(/^#[^\s]+$/g) !== null) { | ||
// It's an id selector and a valid id, as it does not contain any white space characters | ||
return this.pageScrollOptions.document.getElementById(targetSelector.substr(1)); | ||
function () { | ||
if (typeof this.pageScrollOptions.scrollTarget === 'string') { | ||
/** @type {?} */ | ||
var targetSelector = ( /** @type {?} */(this.pageScrollOptions.scrollTarget)); | ||
if (targetSelector.match(/^#[^\s]+$/g) !== null) { | ||
// It's an id selector and a valid id, as it does not contain any white space characters | ||
return this.pageScrollOptions.document.getElementById(targetSelector.substr(1)); | ||
} | ||
return ( /** @type {?} */(this.pageScrollOptions.document.querySelector(targetSelector))); | ||
} | ||
return (/** @type {?} */ (this.pageScrollOptions.document.querySelector(targetSelector))); | ||
} | ||
return (/** @type {?} */ (this.pageScrollOptions.scrollTarget)); | ||
}; | ||
return ( /** @type {?} */(this.pageScrollOptions.scrollTarget)); | ||
}; | ||
return PageScrollInstance; | ||
@@ -411,14 +407,3 @@ }()); | ||
/** @type {?} */ | ||
var NGXPS_CONFIG = new core.InjectionToken('ngxps_config'); | ||
var ɵ0 = /** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
function (t, b, c, d) { | ||
// Linear easing | ||
return c * t / d + b; | ||
}; | ||
var NGXPS_CONFIG = new i0.InjectionToken('ngxps_config'); | ||
/** @type {?} */ | ||
@@ -437,3 +422,12 @@ var defaultPageScrollConfig = { | ||
interruptible: true, | ||
easingLogic: (ɵ0), | ||
easingLogic: ( /** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/function (t, b, c, d) { | ||
// Linear easing | ||
return c * t / d + b; | ||
}), | ||
}; | ||
@@ -450,8 +444,7 @@ | ||
this.onInterrupted = { | ||
report: (/** | ||
report: ( /** | ||
* @param {?} event | ||
* @param {?} pageScrollInstance | ||
* @return {?} | ||
*/ | ||
function (event, pageScrollInstance) { | ||
*/function (event, pageScrollInstance) { | ||
if (!pageScrollInstance.pageScrollOptions.interruptible) { | ||
@@ -465,3 +458,3 @@ // Non-interruptible anyway, so do not stop anything | ||
// Only stop if specific keys have been pressed, for all others don't stop anything | ||
if (_this.config.interruptKeys.indexOf(((/** @type {?} */ (event))).key) === -1) { | ||
if (_this.config.interruptKeys.indexOf((( /** @type {?} */(event))).key) === -1) { | ||
// The pressed key is not in the list of interrupting keys | ||
@@ -474,7 +467,6 @@ shouldStop = false; | ||
// been clicked inside the scrolling container | ||
if (!pageScrollInstance.pageScrollOptions.scrollViews.some((/** | ||
if (!pageScrollInstance.pageScrollOptions.scrollViews.some(( /** | ||
* @param {?} scrollingView | ||
* @return {?} | ||
*/ | ||
function (scrollingView) { return scrollingView.contains((/** @type {?} */ (event.target))); }))) { | ||
*/function (scrollingView) { return scrollingView.contains(( /** @type {?} */(event.target))); }))) { | ||
// Mouse clicked an element which is not inside any of the the scrolling containers | ||
@@ -491,3 +483,3 @@ shouldStop = false; | ||
if (PageScrollService.instanceCounter > 0 && | ||
(this.config._logLevel >= 2 || (this.config._logLevel >= 1 && core.isDevMode()))) { | ||
(this.config._logLevel >= 2 || (this.config._logLevel >= 1 && i0.isDevMode()))) { | ||
console.warn('An instance of PageScrollService already exists, usually ' + | ||
@@ -510,21 +502,21 @@ 'including one provider should be enough, so double check.'); | ||
*/ | ||
function (interrupted, pageScrollInstance) { | ||
/** @type {?} */ | ||
var index = this.runningInstances.indexOf(pageScrollInstance); | ||
if (index >= 0) { | ||
this.runningInstances.splice(index, 1); | ||
} | ||
if (pageScrollInstance.interruptListenersAttached) { | ||
pageScrollInstance.detachInterruptListeners(); | ||
} | ||
if (pageScrollInstance.timer) { | ||
// Clear/Stop the timer | ||
clearInterval(pageScrollInstance.timer); | ||
// Clear the reference to this timer | ||
pageScrollInstance.timer = undefined; | ||
pageScrollInstance.fireEvent(!interrupted); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
function (interrupted, pageScrollInstance) { | ||
/** @type {?} */ | ||
var index = this.runningInstances.indexOf(pageScrollInstance); | ||
if (index >= 0) { | ||
this.runningInstances.splice(index, 1); | ||
} | ||
if (pageScrollInstance.interruptListenersAttached) { | ||
pageScrollInstance.detachInterruptListeners(); | ||
} | ||
if (pageScrollInstance.timer) { | ||
// Clear/Stop the timer | ||
clearInterval(pageScrollInstance.timer); | ||
// Clear the reference to this timer | ||
pageScrollInstance.timer = undefined; | ||
pageScrollInstance.fireEvent(!interrupted); | ||
return true; | ||
} | ||
return false; | ||
}; | ||
/** | ||
@@ -538,5 +530,5 @@ * @param {?} options | ||
*/ | ||
function (options) { | ||
return new PageScrollInstance((/** @type {?} */ (__assign({}, this.config, options)))); | ||
}; | ||
function (options) { | ||
return new PageScrollInstance(( /** @type {?} */(__assign({}, this.config, options)))); | ||
}; | ||
/** | ||
@@ -563,136 +555,134 @@ * Start a scroll animation. All properties of the animation are stored in the given {@link PageScrollInstance} object. | ||
*/ | ||
// tslint:disable-next-line:cyclomatic-complexity | ||
function (pageScrollInstance) { | ||
var _this = this; | ||
// Merge the default options in the pageScrollInstance options | ||
pageScrollInstance.pageScrollOptions = (/** @type {?} */ (__assign({}, this.config, pageScrollInstance.pageScrollOptions))); | ||
// Stop all possibly running scroll animations in the same namespace | ||
this.stopAll(pageScrollInstance.pageScrollOptions.namespace); | ||
if (pageScrollInstance.pageScrollOptions.scrollViews === null || pageScrollInstance.pageScrollOptions.scrollViews.length === 0) { | ||
// No scrollViews specified, thus we can't animate anything | ||
if (this.config._logLevel >= 2 || (this.config._logLevel >= 1 && core.isDevMode())) { | ||
console.warn('No scrollViews specified, thus ngx-page-scroll does not know which DOM elements to scroll'); | ||
} | ||
return; | ||
} | ||
/** @type {?} */ | ||
var startScrollPositionFound = false; | ||
// Reset start scroll position to 0. If any of the scrollViews has a different one, it will be extracted next | ||
pageScrollInstance.startScrollPosition = 0; | ||
// Get the start scroll position from the scrollViews (e.g. if the user already scrolled down the content) | ||
pageScrollInstance.pageScrollOptions.scrollViews.forEach((/** | ||
* @param {?} scrollingView | ||
* @return {?} | ||
*/ | ||
function (scrollingView) { | ||
if (scrollingView === undefined || scrollingView === null) { | ||
// tslint:disable-next-line:cyclomatic-complexity | ||
function (pageScrollInstance) { | ||
var _this = this; | ||
// Merge the default options in the pageScrollInstance options | ||
pageScrollInstance.pageScrollOptions = ( /** @type {?} */(__assign({}, this.config, pageScrollInstance.pageScrollOptions))); | ||
// Stop all possibly running scroll animations in the same namespace | ||
this.stopAll(pageScrollInstance.pageScrollOptions.namespace); | ||
if (pageScrollInstance.pageScrollOptions.scrollViews === null || pageScrollInstance.pageScrollOptions.scrollViews.length === 0) { | ||
// No scrollViews specified, thus we can't animate anything | ||
if (this.config._logLevel >= 2 || (this.config._logLevel >= 1 && i0.isDevMode())) { | ||
console.warn('No scrollViews specified, thus ngx-page-scroll does not know which DOM elements to scroll'); | ||
} | ||
return; | ||
} | ||
// Get the scrollTop or scrollLeft value of the first scrollingView that returns a value for its "scrollTop" | ||
// or "scrollLeft" property that is not undefined and unequal to 0 | ||
/** @type {?} */ | ||
var scrollPosition = pageScrollInstance.getScrollPropertyValue(scrollingView); | ||
if (!startScrollPositionFound && scrollPosition) { | ||
// We found a scrollingView that does not have scrollTop or scrollLeft 0 | ||
// Return the scroll position value, as this will be our startScrollPosition | ||
pageScrollInstance.startScrollPosition = scrollPosition; | ||
startScrollPositionFound = true; | ||
} | ||
})); | ||
/** @type {?} */ | ||
var pageScrollOffset = pageScrollInstance.getCurrentOffset(); | ||
// Calculate the target position that the scroll animation should go to | ||
/** @type {?} */ | ||
var scrollTargetPosition = pageScrollInstance.extractScrollTargetPosition(); | ||
pageScrollInstance.targetScrollPosition = Math.round((pageScrollInstance.pageScrollOptions.verticalScrolling ? scrollTargetPosition.top : scrollTargetPosition.left) - pageScrollOffset); | ||
// Calculate the distance we need to go in total | ||
pageScrollInstance.distanceToScroll = pageScrollInstance.targetScrollPosition - pageScrollInstance.startScrollPosition; | ||
if (isNaN(pageScrollInstance.distanceToScroll)) { | ||
// We weren't able to find the target position, maybe the element does not exist? | ||
if (this.config._logLevel >= 2 || (this.config._logLevel >= 1 && core.isDevMode())) { | ||
console.log('Scrolling not possible, as we can\'t find the specified target'); | ||
} | ||
pageScrollInstance.fireEvent(false); | ||
return; | ||
} | ||
// We're at the final destination already | ||
// OR we need to scroll down but are already at the end | ||
// OR we need to scroll up but are at the top already | ||
/** @type {?} */ | ||
var allReadyAtDestination = Math.abs(pageScrollInstance.distanceToScroll) < pageScrollInstance.pageScrollOptions._minScrollDistance; | ||
// Check how long we need to scroll if a speed option is given | ||
// Default executionDuration is the specified duration | ||
pageScrollInstance.executionDuration = pageScrollInstance.pageScrollOptions.duration; | ||
// Maybe we need to pay attention to the speed option? | ||
if ((pageScrollInstance.pageScrollOptions.speed !== undefined && pageScrollInstance.pageScrollOptions.speed !== null) && | ||
(pageScrollInstance.pageScrollOptions.duration === undefined || pageScrollInstance.pageScrollOptions.duration === null)) { | ||
// Speed option is set and no duration => calculate duration based on speed and scroll distance | ||
pageScrollInstance.executionDuration = | ||
Math.abs(pageScrollInstance.distanceToScroll) / pageScrollInstance.pageScrollOptions.speed * 1000; | ||
} | ||
// We should go there directly, as our "animation" would have one big step | ||
// only anyway and this way we save the interval stuff | ||
/** @type {?} */ | ||
var tooShortInterval = pageScrollInstance.executionDuration <= pageScrollInstance.pageScrollOptions._interval; | ||
if (allReadyAtDestination || tooShortInterval) { | ||
if (this.config._logLevel >= 2 || (this.config._logLevel >= 1 && core.isDevMode())) { | ||
if (allReadyAtDestination) { | ||
console.log('Scrolling not possible, as we can\'t get any closer to the destination'); | ||
var startScrollPositionFound = false; | ||
// Reset start scroll position to 0. If any of the scrollViews has a different one, it will be extracted next | ||
pageScrollInstance.startScrollPosition = 0; | ||
// Get the start scroll position from the scrollViews (e.g. if the user already scrolled down the content) | ||
pageScrollInstance.pageScrollOptions.scrollViews.forEach(( /** | ||
* @param {?} scrollingView | ||
* @return {?} | ||
*/function (scrollingView) { | ||
if (scrollingView === undefined || scrollingView === null) { | ||
return; | ||
} | ||
else { | ||
console.log('Scroll duration shorter that interval length, jumping to target'); | ||
// Get the scrollTop or scrollLeft value of the first scrollingView that returns a value for its "scrollTop" | ||
// or "scrollLeft" property that is not undefined and unequal to 0 | ||
/** @type {?} */ | ||
var scrollPosition = pageScrollInstance.getScrollPropertyValue(scrollingView); | ||
if (!startScrollPositionFound && scrollPosition) { | ||
// We found a scrollingView that does not have scrollTop or scrollLeft 0 | ||
// Return the scroll position value, as this will be our startScrollPosition | ||
pageScrollInstance.startScrollPosition = scrollPosition; | ||
startScrollPositionFound = true; | ||
} | ||
} | ||
pageScrollInstance.setScrollPosition(pageScrollInstance.targetScrollPosition); | ||
pageScrollInstance.fireEvent(true); | ||
return; | ||
} | ||
// Register the interrupt listeners if we want an interruptible scroll animation | ||
if (pageScrollInstance.pageScrollOptions.interruptible) { | ||
pageScrollInstance.attachInterruptListeners(this.onInterrupted); | ||
} | ||
// Let's get started, get the start time... | ||
pageScrollInstance.startTime = new Date().getTime(); | ||
// .. and calculate the end time (when we need to finish at last) | ||
pageScrollInstance.endTime = pageScrollInstance.startTime + pageScrollInstance.executionDuration; | ||
pageScrollInstance.timer = setInterval((/** | ||
* @param {?} _pageScrollInstance | ||
* @return {?} | ||
*/ | ||
function (_pageScrollInstance) { | ||
// Take the current time | ||
})); | ||
/** @type {?} */ | ||
var currentTime = new Date().getTime(); | ||
// Determine the new scroll position | ||
var pageScrollOffset = pageScrollInstance.getCurrentOffset(); | ||
// Calculate the target position that the scroll animation should go to | ||
/** @type {?} */ | ||
var newScrollPosition; | ||
var scrollTargetPosition = pageScrollInstance.extractScrollTargetPosition(); | ||
pageScrollInstance.targetScrollPosition = Math.round((pageScrollInstance.pageScrollOptions.verticalScrolling ? scrollTargetPosition.top : scrollTargetPosition.left) - pageScrollOffset); | ||
// Calculate the distance we need to go in total | ||
pageScrollInstance.distanceToScroll = pageScrollInstance.targetScrollPosition - pageScrollInstance.startScrollPosition; | ||
if (isNaN(pageScrollInstance.distanceToScroll)) { | ||
// We weren't able to find the target position, maybe the element does not exist? | ||
if (this.config._logLevel >= 2 || (this.config._logLevel >= 1 && i0.isDevMode())) { | ||
console.log('Scrolling not possible, as we can\'t find the specified target'); | ||
} | ||
pageScrollInstance.fireEvent(false); | ||
return; | ||
} | ||
// We're at the final destination already | ||
// OR we need to scroll down but are already at the end | ||
// OR we need to scroll up but are at the top already | ||
/** @type {?} */ | ||
var stopNow = false; | ||
if (_pageScrollInstance.endTime <= currentTime) { | ||
// We're over the time already, so go the targetScrollPosition (aka destination) | ||
newScrollPosition = _pageScrollInstance.targetScrollPosition; | ||
stopNow = true; | ||
var allReadyAtDestination = Math.abs(pageScrollInstance.distanceToScroll) < pageScrollInstance.pageScrollOptions._minScrollDistance; | ||
// Check how long we need to scroll if a speed option is given | ||
// Default executionDuration is the specified duration | ||
pageScrollInstance.executionDuration = pageScrollInstance.pageScrollOptions.duration; | ||
// Maybe we need to pay attention to the speed option? | ||
if ((pageScrollInstance.pageScrollOptions.speed !== undefined && pageScrollInstance.pageScrollOptions.speed !== null) && | ||
(pageScrollInstance.pageScrollOptions.duration === undefined || pageScrollInstance.pageScrollOptions.duration === null)) { | ||
// Speed option is set and no duration => calculate duration based on speed and scroll distance | ||
pageScrollInstance.executionDuration = | ||
Math.abs(pageScrollInstance.distanceToScroll) / pageScrollInstance.pageScrollOptions.speed * 1000; | ||
} | ||
else { | ||
// Calculate the scroll position based on the current time using the easing function | ||
newScrollPosition = Math.round(_pageScrollInstance.pageScrollOptions.easingLogic(currentTime - _pageScrollInstance.startTime, _pageScrollInstance.startScrollPosition, _pageScrollInstance.distanceToScroll, _pageScrollInstance.executionDuration)); | ||
// We should go there directly, as our "animation" would have one big step | ||
// only anyway and this way we save the interval stuff | ||
/** @type {?} */ | ||
var tooShortInterval = pageScrollInstance.executionDuration <= pageScrollInstance.pageScrollOptions._interval; | ||
if (allReadyAtDestination || tooShortInterval) { | ||
if (this.config._logLevel >= 2 || (this.config._logLevel >= 1 && i0.isDevMode())) { | ||
if (allReadyAtDestination) { | ||
console.log('Scrolling not possible, as we can\'t get any closer to the destination'); | ||
} | ||
else { | ||
console.log('Scroll duration shorter that interval length, jumping to target'); | ||
} | ||
} | ||
pageScrollInstance.setScrollPosition(pageScrollInstance.targetScrollPosition); | ||
pageScrollInstance.fireEvent(true); | ||
return; | ||
} | ||
if (_this.config._logLevel >= 5 && core.isDevMode()) { | ||
console.warn('Scroll Position: ' + newScrollPosition); | ||
// Register the interrupt listeners if we want an interruptible scroll animation | ||
if (pageScrollInstance.pageScrollOptions.interruptible) { | ||
pageScrollInstance.attachInterruptListeners(this.onInterrupted); | ||
} | ||
// Set the new scrollPosition to all scrollViews elements | ||
if (!_pageScrollInstance.setScrollPosition(newScrollPosition)) { | ||
// Setting the new scrollTop/scrollLeft value failed for all ScrollViews | ||
// early stop the scroll animation to save resources | ||
stopNow = true; | ||
} | ||
// At the end do the internal stop maintenance and fire the pageScrollFinish event | ||
// (otherwise the event might arrive at "too early") | ||
if (stopNow) { | ||
_this.stopInternal(false, _pageScrollInstance); | ||
} | ||
}), this.config._interval, pageScrollInstance); | ||
// Register the instance as running one | ||
this.runningInstances.push(pageScrollInstance); | ||
}; | ||
// Let's get started, get the start time... | ||
pageScrollInstance.startTime = new Date().getTime(); | ||
// .. and calculate the end time (when we need to finish at last) | ||
pageScrollInstance.endTime = pageScrollInstance.startTime + pageScrollInstance.executionDuration; | ||
pageScrollInstance.timer = setInterval(( /** | ||
* @param {?} _pageScrollInstance | ||
* @return {?} | ||
*/function (_pageScrollInstance) { | ||
// Take the current time | ||
/** @type {?} */ | ||
var currentTime = new Date().getTime(); | ||
// Determine the new scroll position | ||
/** @type {?} */ | ||
var newScrollPosition; | ||
/** @type {?} */ | ||
var stopNow = false; | ||
if (_pageScrollInstance.endTime <= currentTime) { | ||
// We're over the time already, so go the targetScrollPosition (aka destination) | ||
newScrollPosition = _pageScrollInstance.targetScrollPosition; | ||
stopNow = true; | ||
} | ||
else { | ||
// Calculate the scroll position based on the current time using the easing function | ||
newScrollPosition = Math.round(_pageScrollInstance.pageScrollOptions.easingLogic(currentTime - _pageScrollInstance.startTime, _pageScrollInstance.startScrollPosition, _pageScrollInstance.distanceToScroll, _pageScrollInstance.executionDuration)); | ||
} | ||
if (_this.config._logLevel >= 5 && i0.isDevMode()) { | ||
console.warn('Scroll Position: ' + newScrollPosition); | ||
} | ||
// Set the new scrollPosition to all scrollViews elements | ||
if (!_pageScrollInstance.setScrollPosition(newScrollPosition)) { | ||
// Setting the new scrollTop/scrollLeft value failed for all ScrollViews | ||
// early stop the scroll animation to save resources | ||
stopNow = true; | ||
} | ||
// At the end do the internal stop maintenance and fire the pageScrollFinish event | ||
// (otherwise the event might arrive at "too early") | ||
if (stopNow) { | ||
_this.stopInternal(false, _pageScrollInstance); | ||
} | ||
}), this.config._interval, pageScrollInstance); | ||
// Register the instance as running one | ||
this.runningInstances.push(pageScrollInstance); | ||
}; | ||
/** | ||
@@ -706,5 +696,5 @@ * @param {?} options | ||
*/ | ||
function (options) { | ||
this.start(this.create(options)); | ||
}; | ||
function (options) { | ||
this.start(this.create(options)); | ||
}; | ||
/** | ||
@@ -723,20 +713,20 @@ * Stop all running scroll animations. Optionally limit to stop only the ones of specific namespace. | ||
*/ | ||
function (namespace) { | ||
if (this.runningInstances.length > 0) { | ||
/** @type {?} */ | ||
var stoppedSome = false; | ||
for (var i = 0; i < this.runningInstances.length; ++i) { | ||
function (namespace) { | ||
if (this.runningInstances.length > 0) { | ||
/** @type {?} */ | ||
var pageScrollInstance = this.runningInstances[i]; | ||
if (!namespace || pageScrollInstance.pageScrollOptions.namespace === namespace) { | ||
stoppedSome = true; | ||
this.stopInternal(true, pageScrollInstance); | ||
// Decrease the counter, as we removed an item from the array we iterate over | ||
i--; | ||
var stoppedSome = false; | ||
for (var i = 0; i < this.runningInstances.length; ++i) { | ||
/** @type {?} */ | ||
var pageScrollInstance = this.runningInstances[i]; | ||
if (!namespace || pageScrollInstance.pageScrollOptions.namespace === namespace) { | ||
stoppedSome = true; | ||
this.stopInternal(true, pageScrollInstance); | ||
// Decrease the counter, as we removed an item from the array we iterate over | ||
i--; | ||
} | ||
} | ||
return stoppedSome; | ||
} | ||
return stoppedSome; | ||
} | ||
return false; | ||
}; | ||
return false; | ||
}; | ||
/** | ||
@@ -750,8 +740,8 @@ * @param {?} pageScrollInstance | ||
*/ | ||
function (pageScrollInstance) { | ||
return this.stopInternal(true, pageScrollInstance); | ||
}; | ||
function (pageScrollInstance) { | ||
return this.stopInternal(true, pageScrollInstance); | ||
}; | ||
PageScrollService.instanceCounter = 0; | ||
PageScrollService.decorators = [ | ||
{ type: core.Injectable, args: [{ | ||
{ type: i0.Injectable, args: [{ | ||
providedIn: 'root', | ||
@@ -761,6 +751,8 @@ },] } | ||
/** @nocollapse */ | ||
PageScrollService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXPS_CONFIG,] }] } | ||
]; }; | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(core.ɵɵinject(NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
PageScrollService.ctorParameters = function () { | ||
return [ | ||
{ type: undefined, decorators: [{ type: i0.Inject, args: [NGXPS_CONFIG,] }] } | ||
]; | ||
}; | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = i0.defineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(i0.inject(NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
return PageScrollService; | ||
@@ -773,3 +765,3 @@ }()); | ||
*/ | ||
var ɵ0$1 = {}; | ||
var ɵ0 = {}; | ||
var NgxPageScrollCoreModule = /** @class */ (function () { | ||
@@ -786,13 +778,13 @@ function NgxPageScrollCoreModule() { | ||
*/ | ||
function (config) { | ||
return { | ||
ngModule: NgxPageScrollCoreModule, | ||
providers: [PageScrollService, { provide: NGXPS_CONFIG, useValue: config }], | ||
function (config) { | ||
return { | ||
ngModule: NgxPageScrollCoreModule, | ||
providers: [PageScrollService, { provide: NGXPS_CONFIG, useValue: config }], | ||
}; | ||
}; | ||
}; | ||
NgxPageScrollCoreModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
{ type: i0.NgModule, args: [{ | ||
providers: [ | ||
PageScrollService, | ||
{ provide: NGXPS_CONFIG, useValue: ɵ0$1 }, | ||
{ provide: NGXPS_CONFIG, useValue: ɵ0 }, | ||
], | ||
@@ -804,11 +796,22 @@ },] } | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
exports.NgxPageScrollCoreModule = NgxPageScrollCoreModule; | ||
exports.NGXPS_CONFIG = NGXPS_CONFIG; | ||
exports.NgxPageScrollCoreModule = NgxPageScrollCoreModule; | ||
exports.defaultPageScrollConfig = defaultPageScrollConfig; | ||
exports.PageScrollService = PageScrollService; | ||
exports.PageScrollInstance = PageScrollInstance; | ||
exports.PageScrollService = PageScrollService; | ||
exports.defaultPageScrollConfig = defaultPageScrollConfig; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=ngx-page-scroll-core.umd.js.map | ||
}))); | ||
//# sourceMappingURL=ngx-page-scroll-core.umd.js.map |
@@ -1,2 +0,2 @@ | ||
!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=e||self)["ngx-page-scroll-core"]={},e.ng.core)}(this,function(e,t){"use strict";var n=function(){return(n=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)},o=function(){function e(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 e.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)}},e.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},e.prototype.getScrollPropertyValue=function(e){return this.pageScrollOptions.verticalScrolling?e.scrollTop:e.scrollLeft},e.prototype.extractScrollTargetPosition=function(){var t=this.getScrollTargetElement();return null===t||t===undefined?{top:NaN,left:NaN}:this.isInlineScrolling?e.getInlineScrollingTargetPosition(this.pageScrollOptions,t):e.getScrollingTargetPosition(this.pageScrollOptions,t)},e.prototype.getCurrentOffset=function(){return this.pageScrollOptions.scrollOffset},e.prototype.setScrollPosition=function(e){var t=this;return this.pageScrollOptions.scrollViews.reduce(function(n,o){var r=t.getScrollPropertyValue(o);if(o&&r!==undefined&&null!==r){var i=Math.abs(r-e),l=i<t.pageScrollOptions._minScrollDistance;if(t.pageScrollOptions.verticalScrolling?o.scrollTop=e:o.scrollLeft=e,l||i>Math.abs(t.getScrollPropertyValue(o)-e))return!0}return n},!1)},e.prototype.fireEvent=function(e){this.pageScrollOptions.scrollFinishListener&&this.pageScrollOptions.scrollFinishListener.emit(e)},e.prototype.attachInterruptListeners=function(e){var t=this;this.interruptListenersAttached&&this.detachInterruptListeners(),this.interruptListener=function(n){e.report(n,t)},this.pageScrollOptions.interruptEvents.forEach(function(e){return t.pageScrollOptions.document.body.addEventListener(e,t.interruptListener)}),this.interruptListenersAttached=!0},e.prototype.detachInterruptListeners=function(){var e=this;this.pageScrollOptions.interruptEvents.forEach(function(t){return e.pageScrollOptions.document.body.removeEventListener(t,e.interruptListener)}),this.interruptListenersAttached=!1},e.prototype.getScrollTargetElement=function(){if("string"==typeof 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)}return this.pageScrollOptions.scrollTarget},e}(),r=new t.InjectionToken("ngxps_config"),i={_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}},l=function(){function e(o){var r=this;this.runningInstances=[],this.onInterrupted={report:function(e,t){if(t.pageScrollOptions.interruptible){var n=!0;"keyup"===e.type?-1===r.config.interruptKeys.indexOf(e.key)&&(n=!1):"mousedown"===e.type&&(t.pageScrollOptions.scrollViews.some(function(t){return t.contains(e.target)})||(n=!1)),n&&r.stopAll(t.pageScrollOptions.namespace)}}},this.config=n({},i,o),e.instanceCounter>0&&(this.config._logLevel>=2||this.config._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=undefined,t.fireEvent(!e),!0)},e.prototype.create=function(e){return new o(n({},this.config,e))},e.prototype.start=function(e){var o=this;if(e.pageScrollOptions=n({},this.config,e.pageScrollOptions),this.stopAll(e.pageScrollOptions.namespace),null!==e.pageScrollOptions.scrollViews&&0!==e.pageScrollOptions.scrollViews.length){var r=!1;e.startScrollPosition=0,e.pageScrollOptions.scrollViews.forEach(function(t){if(t!==undefined&&null!==t){var n=e.getScrollPropertyValue(t);!r&&n&&(e.startScrollPosition=n,r=!0)}});var i=e.getCurrentOffset(),l=e.extractScrollTargetPosition();if(e.targetScrollPosition=Math.round((e.pageScrollOptions.verticalScrolling?l.top:l.left)-i),e.distanceToScroll=e.targetScrollPosition-e.startScrollPosition,isNaN(e.distanceToScroll))return(this.config._logLevel>=2||this.config._logLevel>=1&&t.isDevMode())&&console.log("Scrolling not possible, as we can't find the specified target"),void e.fireEvent(!1);var s=Math.abs(e.distanceToScroll)<e.pageScrollOptions._minScrollDistance;e.executionDuration=e.pageScrollOptions.duration,e.pageScrollOptions.speed===undefined||null===e.pageScrollOptions.speed||e.pageScrollOptions.duration!==undefined&&null!==e.pageScrollOptions.duration||(e.executionDuration=Math.abs(e.distanceToScroll)/e.pageScrollOptions.speed*1e3);var c=e.executionDuration<=e.pageScrollOptions._interval;if(s||c)return(this.config._logLevel>=2||this.config._logLevel>=1&&t.isDevMode())&&(s?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.pageScrollOptions.interruptible&&e.attachInterruptListeners(this.onInterrupted),e.startTime=(new Date).getTime(),e.endTime=e.startTime+e.executionDuration,e.timer=setInterval(function(e){var n,r=(new Date).getTime(),i=!1;e.endTime<=r?(n=e.targetScrollPosition,i=!0):n=Math.round(e.pageScrollOptions.easingLogic(r-e.startTime,e.startScrollPosition,e.distanceToScroll,e.executionDuration)),o.config._logLevel>=5&&t.isDevMode()&&console.warn("Scroll Position: "+n),e.setScrollPosition(n)||(i=!0),i&&o.stopInternal(!1,e)},this.config._interval,e),this.runningInstances.push(e)}else(this.config._logLevel>=2||this.config._logLevel>=1&&t.isDevMode())&&console.warn("No scrollViews specified, thus ngx-page-scroll does not know which DOM elements to scroll")},e.prototype.scroll=function(e){this.start(this.create(e))},e.prototype.stopAll=function(e){if(this.runningInstances.length>0){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},e.prototype.stop=function(e){return this.stopInternal(!0,e)},e.instanceCounter=0,e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:undefined,decorators:[{type:t.Inject,args:[r]}]}]},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(r))},token:e,providedIn:"root"}),e}(),s={},c=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[l,{provide:r,useValue:t}]}},e.decorators=[{type:t.NgModule,args:[{providers:[l,{provide:r,useValue:s}]}]}],e}();e.NGXPS_CONFIG=r,e.NgxPageScrollCoreModule=c,e.PageScrollInstance=o,e.PageScrollService=l,e.defaultPageScrollConfig=i,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!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 |
@@ -8,13 +8,2 @@ /** | ||
export const NGXPS_CONFIG = new InjectionToken('ngxps_config'); | ||
const ɵ0 = /** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
(t, b, c, d) => { | ||
// Linear easing | ||
return c * t / d + b; | ||
}; | ||
/** @type {?} */ | ||
@@ -33,5 +22,14 @@ export const defaultPageScrollConfig = { | ||
interruptible: true, | ||
easingLogic: (ɵ0), | ||
easingLogic: (/** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
(t, b, c, d) => { | ||
// Linear easing | ||
return c * t / d + b; | ||
}), | ||
}; | ||
export { ɵ0 }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLnByb3ZpZGVyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmd4LXBhZ2Utc2Nyb2xsLWNvcmUvIiwic291cmNlcyI6WyJsaWIvcHJvdmlkZXJzL2NvbmZpZy5wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFHL0MsTUFBTSxPQUFPLFlBQVksR0FBRyxJQUFJLGNBQWMsQ0FBbUIsY0FBYyxDQUFDOzs7Ozs7OztBQWNqRSxDQUFDLENBQVMsRUFBRSxDQUFTLEVBQUUsQ0FBUyxFQUFFLENBQVMsRUFBVSxFQUFFO0lBQ2xFLGdCQUFnQjtJQUNoQixPQUFPLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUN2QixDQUFDOztBQWZILE1BQU0sT0FBTyx1QkFBdUIsR0FBcUI7SUFDdkQsU0FBUyxFQUFFLEVBQUU7SUFDYixrQkFBa0IsRUFBRSxDQUFDO0lBQ3JCLFNBQVMsRUFBRSxDQUFDO0lBQ1osU0FBUyxFQUFFLFNBQVM7SUFDcEIsaUJBQWlCLEVBQUUsSUFBSTtJQUN2QixRQUFRLEVBQUUsSUFBSTtJQUNkLFlBQVksRUFBRSxDQUFDO0lBQ2YsK0JBQStCLEVBQUUsS0FBSztJQUN0QyxlQUFlLEVBQUUsQ0FBQyxXQUFXLEVBQUUsT0FBTyxFQUFFLGdCQUFnQixFQUFFLFlBQVksRUFBRSxPQUFPLEVBQUUsV0FBVyxDQUFD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saW5lT2Zmc2V0Q2FsY3VsYXRpb246IGZhbHNlLFxuICBpbnRlcnJ1cHRFdmVudHM6IFsnbW91c2Vkb3duJywgJ3doZWVsJywgJ0RPTU1vdXNlU2Nyb2xsJywgJ21vdXNld2hlZWwnLCAna2V5dXAnLCAndG91Y2htb3ZlJ10sXG4gIGludGVycnVwdEtleXM6IFsnICcsICdFc2NhcGUnLCAnVGFiJywgJ0VudGVyJywgJ1BhZ2VVcCcsICdQYWdlRG93bicsICdIb21lJywgJ0VuZCcsICdBcnJvd1VwJywgJ0Fycm93UmlnaHQnLCAnQXJyb3dMZWZ0JywgJ0Fycm93RG93biddLFxuICBpbnRlcnJ1cHRpYmxlOiB0cnVlLFxuICBlYXNpbmdMb2dpYzogKHQ6IG51bWJlciwgYjogbnVtYmVyLCBjOiBudW1iZXIsIGQ6IG51bWJlcik6IG51bWJlciA9PiB7XG4gICAgLy8gTGluZWFyIGVhc2luZ1xuICAgIHJldHVybiBjICogdCAvIGQgKyBiO1xuICB9LFxufTtcbiJdfQ== |
@@ -281,3 +281,3 @@ /** | ||
]; | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(i0.ɵɵinject(i1.NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = i0.defineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(i0.inject(i1.NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
if (false) { | ||
@@ -284,0 +284,0 @@ /** |
@@ -8,13 +8,2 @@ /** | ||
export var NGXPS_CONFIG = new InjectionToken('ngxps_config'); | ||
var ɵ0 = /** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
function (t, b, c, d) { | ||
// Linear easing | ||
return c * t / d + b; | ||
}; | ||
/** @type {?} */ | ||
@@ -33,5 +22,14 @@ export var defaultPageScrollConfig = { | ||
interruptible: true, | ||
easingLogic: (ɵ0), | ||
easingLogic: (/** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
function (t, b, c, d) { | ||
// Linear easing | ||
return c * t / d + b; | ||
}), | ||
}; | ||
export { ɵ0 }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLnByb3ZpZGVyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmd4LXBhZ2Utc2Nyb2xsLWNvcmUvIiwic291cmNlcyI6WyJsaWIvcHJvdmlkZXJzL2NvbmZpZy5wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFHL0MsTUFBTSxLQUFPLFlBQVksR0FBRyxJQUFJLGNBQWMsQ0FBbUIsY0FBYyxDQUFDOzs7Ozs7OztBQWNqRSxVQUFDLENBQVMsRUFBRSxDQUFTLEVBQUUsQ0FBUyxFQUFFLENBQVM7SUFDdEQsZ0JBQWdCO0lBQ2hCLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ3ZCLENBQUM7O0FBZkgsTUFBTSxLQUFPLHVCQUF1QixHQUFxQjtJQUN2RCxTQUFTLEVBQUUsRUFBRTtJQUNiLGtCQUFrQixFQUFFLENBQUM7SUFDckIsU0FBUyxFQUFFLENBQUM7SUFDWixTQUFTLEVBQUUsU0FBUztJQUNwQixpQkFBaUIsRUFBRSxJQUFJO0lBQ3ZCLFFBQVEsRUFBRSxJQUFJO0lBQ2QsWUFBWSxFQUFFLENBQUM7SUFDZiwrQkFBK0IsRUFBRSxLQUFLO0lBQ3RDLGVBQWUsRUFBRSxDQUFDLFdBQVcsRUFBRSxPQUFPLEVBQUUsZ0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9mZnNldDogMCxcbiAgYWR2YW5jZWRJbmxpbmVPZmZzZXRDYWxjdWxhdGlvbjogZmFsc2UsXG4gIGludGVycnVwdEV2ZW50czogWydtb3VzZWRvd24nLCAnd2hlZWwnLCAnRE9NTW91c2VTY3JvbGwnLCAnbW91c2V3aGVlbCcsICdrZXl1cCcsICd0b3VjaG1vdmUnXSxcbiAgaW50ZXJydXB0S2V5czogWycgJywgJ0VzY2FwZScsICdUYWInLCAnRW50ZXInLCAnUGFnZVVwJywgJ1BhZ2VEb3duJywgJ0hvbWUnLCAnRW5kJywgJ0Fycm93VXAnLCAnQXJyb3dSaWdodCcsICdBcnJvd0xlZnQnLCAnQXJyb3dEb3duJ10sXG4gIGludGVycnVwdGlibGU6IHRydWUsXG4gIGVhc2luZ0xvZ2ljOiAodDogbnVtYmVyLCBiOiBudW1iZXIsIGM6IG51bWJlciwgZDogbnVtYmVyKTogbnVtYmVyID0+IHtcbiAgICAvLyBMaW5lYXIgZWFzaW5nXG4gICAgcmV0dXJuIGMgKiB0IC8gZCArIGI7XG4gIH0sXG59O1xuIl19 |
@@ -320,3 +320,3 @@ /** | ||
]; }; | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(i0.ɵɵinject(i1.NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = i0.defineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(i0.inject(i1.NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
return PageScrollService; | ||
@@ -323,0 +323,0 @@ }()); |
@@ -1,2 +0,2 @@ | ||
import { InjectionToken, isDevMode, Injectable, Inject, ɵɵdefineInjectable, ɵɵinject, NgModule } from '@angular/core'; | ||
import { InjectionToken, Inject, Injectable, isDevMode, NgModule, defineInjectable, inject } from '@angular/core'; | ||
@@ -273,13 +273,2 @@ /** | ||
const NGXPS_CONFIG = new InjectionToken('ngxps_config'); | ||
const ɵ0 = /** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
(t, b, c, d) => { | ||
// Linear easing | ||
return c * t / d + b; | ||
}; | ||
/** @type {?} */ | ||
@@ -298,3 +287,13 @@ const defaultPageScrollConfig = { | ||
interruptible: true, | ||
easingLogic: (ɵ0), | ||
easingLogic: (/** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
(t, b, c, d) => { | ||
// Linear easing | ||
return c * t / d + b; | ||
}), | ||
}; | ||
@@ -577,3 +576,3 @@ | ||
]; | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = ɵɵdefineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(ɵɵinject(NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = defineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(inject(NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
@@ -584,3 +583,3 @@ /** | ||
*/ | ||
const ɵ0$1 = {}; | ||
const ɵ0 = {}; | ||
class NgxPageScrollCoreModule { | ||
@@ -602,3 +601,3 @@ /** | ||
PageScrollService, | ||
{ provide: NGXPS_CONFIG, useValue: ɵ0$1 }, | ||
{ provide: NGXPS_CONFIG, useValue: ɵ0 }, | ||
], | ||
@@ -638,3 +637,4 @@ },] } | ||
export { NGXPS_CONFIG, NgxPageScrollCoreModule, PageScrollInstance, PageScrollService, defaultPageScrollConfig }; | ||
//# sourceMappingURL=ngx-page-scroll-core.js.map | ||
export { NgxPageScrollCoreModule, NGXPS_CONFIG, defaultPageScrollConfig, PageScrollService, PageScrollInstance }; | ||
//# sourceMappingURL=ngx-page-scroll-core.js.map |
@@ -1,3 +0,3 @@ | ||
import { InjectionToken, isDevMode, Injectable, Inject, ɵɵdefineInjectable, ɵɵinject, NgModule } from '@angular/core'; | ||
import { __assign } from 'tslib'; | ||
import { InjectionToken, Inject, Injectable, isDevMode, NgModule, defineInjectable, inject } from '@angular/core'; | ||
@@ -371,13 +371,2 @@ /** | ||
var NGXPS_CONFIG = new InjectionToken('ngxps_config'); | ||
var ɵ0 = /** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
function (t, b, c, d) { | ||
// Linear easing | ||
return c * t / d + b; | ||
}; | ||
/** @type {?} */ | ||
@@ -396,3 +385,13 @@ var defaultPageScrollConfig = { | ||
interruptible: true, | ||
easingLogic: (ɵ0), | ||
easingLogic: (/** | ||
* @param {?} t | ||
* @param {?} b | ||
* @param {?} c | ||
* @param {?} d | ||
* @return {?} | ||
*/ | ||
function (t, b, c, d) { | ||
// Linear easing | ||
return c * t / d + b; | ||
}), | ||
}; | ||
@@ -713,3 +712,3 @@ | ||
]; }; | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = ɵɵdefineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(ɵɵinject(NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
/** @nocollapse */ PageScrollService.ngInjectableDef = defineInjectable({ factory: function PageScrollService_Factory() { return new PageScrollService(inject(NGXPS_CONFIG)); }, token: PageScrollService, providedIn: "root" }); | ||
return PageScrollService; | ||
@@ -722,3 +721,3 @@ }()); | ||
*/ | ||
var ɵ0$1 = {}; | ||
var ɵ0 = {}; | ||
var NgxPageScrollCoreModule = /** @class */ (function () { | ||
@@ -745,3 +744,3 @@ function NgxPageScrollCoreModule() { | ||
PageScrollService, | ||
{ provide: NGXPS_CONFIG, useValue: ɵ0$1 }, | ||
{ provide: NGXPS_CONFIG, useValue: ɵ0 }, | ||
], | ||
@@ -783,3 +782,4 @@ },] } | ||
export { NGXPS_CONFIG, NgxPageScrollCoreModule, PageScrollInstance, PageScrollService, defaultPageScrollConfig }; | ||
//# sourceMappingURL=ngx-page-scroll-core.js.map | ||
export { NgxPageScrollCoreModule, NGXPS_CONFIG, defaultPageScrollConfig, PageScrollService, PageScrollInstance }; | ||
//# sourceMappingURL=ngx-page-scroll-core.js.map |
{ | ||
"name": "ngx-page-scroll-core", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"description": "Animated scrolling functionality for angular written in pure typescript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
512424
0
4313