New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seamless-scroll-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seamless-scroll-polyfill - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

9

dist/seamless.browser.min.js

@@ -1,9 +0,2 @@

(function () {
'use strict';
var seamless=function(a){function b(){D=!0,m.clearTimeout(p),p=m.setTimeout(c,q);}function c(){D=!1,m.removeEventListener("wheel",b),m.removeEventListener("touchmove",b);}function d(a,b){if(void 0!==a){if(!0===x(a))return void s.scroll.call(m,void 0===a.left?"object"==typeof a?m.scrollX||m.pageXOffset:a:a.left,void 0===a.top?void 0===b?m.scrollY||m.pageYOffset:b:a.top);var c=a,d=c.left,e=void 0===d?m.scrollX||m.pageXOffset:d,f=c.top,g=void 0===f?m.scrollY||m.pageYOffset:f;E.call(m,o.body,~~e,~~g);}}function e(a,b){return void 0===a?void 0:x(a)?void s.scrollBy.call(m,void 0===a.left?"object"==typeof a?0:a:a.left,void 0===a.top?void 0===b?0:b:a.top):void E.call(m,o.body,~~a.left+(m.scrollX||m.pageXOffset),~~a.top+(m.scrollY||m.pageYOffset))}function f(a,b){if(void 0!==a){if(!0===x(a)){if("number"==typeof a&&void 0===b)throw new SyntaxError("Value could not be converted");return void s.elementScroll.call(this,void 0===a.left?"object"==typeof a?this.scrollLeft:~~a:~~a.left,void 0===a.top?void 0===b?this.scrollTop:~~b:~~a.top)}var c=a,d=c.left,e=void 0===d?this.scrollLeft:d,f=c.top,g=void 0===f?this.scrollTop:f;E.call(this,this,~~e,~~g);}}function g(a,b){return void 0===a?void 0:!0===x(a)?void s.elementScroll.call(this,void 0===a.left?~~a+this.scrollLeft:~~a.left+this.scrollLeft,void 0===a.top?~~b+this.scrollTop:~~a.top+this.scrollTop):void this.scroll({left:~~a.left+this.scrollLeft,top:~~a.top+this.scrollTop,behavior:a.behavior})}var h=void 0===a?{}:a,i=h.force,j=h.duration,k=void 0===j?468:j,l=h.win,m=void 0===l?window:l,n=h.doc,o=void 0===n?document:n;if(!("scrollBehavior"in o.documentElement.style&&!0!==(void 0!==i&&i))){var p,q=~~k,r=function(a,b){this.scrollLeft=a,this.scrollTop=b;},s={scroll:m.scroll||m.scrollTo,scrollBy:m.scrollBy,elementScroll:m.Element.prototype.scroll||r,scrollIntoView:m.Element.prototype.scrollIntoView},t=m.performance&&m.performance.now?m.performance.now.bind(m.performance):Date.now,u=function(a){return new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(a)},v=u(m.navigator.userAgent)?1:0,w=function(a){return .5*(1-Math.cos(Math.PI*a))},x=function(a){if(null===a||"object"!=typeof a||void 0===a.behavior||"auto"===a.behavior||"instant"===a.behavior)return !0;if("object"==typeof a&&"smooth"===a.behavior)return !1;throw new TypeError("behavior member of ScrollOptions "+a.behavior+" is not a valid value for enumeration ScrollBehavior.")},y=function(a,b){return "Y"===b?a.clientHeight+v<a.scrollHeight:"X"===b&&a.clientWidth+v<a.scrollWidth},z=function(a,b){var c=m.getComputedStyle(a,null)["overflow"+b];return "auto"===c||"scroll"===c},A=function(a){var b=y(a,"Y")&&z(a,"Y"),c=y(a,"X")&&z(a,"X");return b||c},B=function(a){var b=a;do b=b.parentElement;while(b!==o.body&&!1===A(b));return b},C=function(a){if(!D){var b=t(),c=(b-a.startTime)/q;c=1<c?1:c;var d=w(c),e=a.startX+(a.x-a.startX)*d,f=a.startY+(a.y-a.startY)*d;a.method.call(a.scrollable,e,f),(e!==a.x||f!==a.y)&&m.requestAnimationFrame(C.bind(m,a));}},D=!1,E=function(a,c,d){var e,f,g,h,i=t();a===o.body?(e=m,f=m.scrollX||m.pageXOffset,g=m.scrollY||m.pageYOffset,h=s.scroll):(e=a,f=a.scrollLeft,g=a.scrollTop,h=r),m.addEventListener("wheel",b,{passive:!0,once:!0}),m.addEventListener("touchmove",b,{passive:!0,once:!0}),C({scrollable:e,method:h,startTime:i,startX:f,startY:g,x:c,y:d});};m.scroll=m.scrollTo=d,m.scrollBy=e,m.Element.prototype.scroll=m.Element.prototype.scrollTo=f,m.Element.prototype.scrollBy=g;var F=function(a,b,c,d){var e=0===b&&c||1===b&&!c?a.inline:a.block;return "center"===e?1:"nearest"===e?0:"start"===e?0===b?d?5:4:2:"end"===e?0===b?d?4:5:3:c?0===b?0:2:0===b?4:0};m.Element.prototype.scrollIntoView=function(a){if(void 0===a||!0===a||!1===a||!0===x(a))return void s.scrollIntoView.call(this,void 0===a||a);var b=B(this),c=b.getBoundingClientRect(),d=this.getBoundingClientRect(),e=c.left,f=c.right,g=c.top,h=c.bottom,i=c.height,j=c.width,k=d.left,l=d.right,n=d.top,p=d.bottom,q=d.height,r=d.width,t=m.innerHeight,u=m.innerWidth,v=m.getComputedStyle(this).writingMode,w="horizontal-tb"===v,y="vertical-rl"===v,z=F(a,0,w,y),A=F(a,1,w,y),C=0,D=0,G=0,H=0,I=0,J=0;switch(z){case 4:C=k-e,I=e,G=k;break;case 1:C=k-e+r/2-j/2,I=(e+f-u)/2,G=(k+l-u)/2;break;case 5:C=l-f,I=f-u,G=l-u;break;case 0:{var K=k+C;k<e&&r<j||l>f&&r>j?(C=k-e,K=e):(k<e&&r>j||l>f&&r<j)&&(C=l-f,K=f-r),0>K&&r<u||K+r>u&&r>u?I=K:(0>K&&r>u||K+r>u&&r<u)&&(I=K+r-u),G=C+I;}}switch(A){case 2:D=n-g,J=g,H=n;break;case 1:D=n-g+q/2-i/2,J=(g+h-t)/2,H=(n+p-t)/2;break;case 3:D=p-h,J=h-t,H=p-t;break;case 0:{var K=n+D;n<g&&q<i||p>h&&q>i?(D=n-g,K=g):(n<g&&q>i||p>h&&q<i)&&(D=p-h,K=h-q),0>K&&q<t||K+q>t&&q>t?J=K:(0>K&&q>t||K+q>t&&q<t)&&(J=K+q-t),H=D+J;}}b===o.body?m.scrollBy({left:G,top:H,behavior:"smooth"}):(E.call(this,b,b.scrollLeft+C,b.scrollTop+D),"fixed"!==m.getComputedStyle(b).position&&m.scrollBy({left:I,top:J,behavior:"smooth"}));};}};
var currentScript="undefined"!=typeof document&&(document.currentScript||document.querySelector("script[data-seamless]"));if(currentScript){var force=currentScript.dataset.polyfill,duration=~~currentScript.dataset.duration;duration=0<duration?duration:void 0,seamless({force:"force"===force,duration:duration});}else global.seamless=seamless;
}());
(function(){'use strict';var a=function(a){function b(){D=!0,m.clearTimeout(p),p=m.setTimeout(c,q)}function c(){D=!1,m.removeEventListener("wheel",b),m.removeEventListener("touchmove",b)}function d(a,b){if(void 0!==a){if(!0===x(a))return void s.scroll.call(m,void 0===a.left?"object"==typeof a?m.scrollX||m.pageXOffset:a:a.left,void 0===a.top?void 0===b?m.scrollY||m.pageYOffset:b:a.top);var c=a,d=c.left,e=void 0===d?m.scrollX||m.pageXOffset:d,f=c.top,g=void 0===f?m.scrollY||m.pageYOffset:f;E.call(m,o.body,~~e,~~g)}}function e(a,b){return void 0===a?void 0:x(a)?void s.scrollBy.call(m,void 0===a.left?"object"==typeof a?0:a:a.left,void 0===a.top?void 0===b?0:b:a.top):void E.call(m,o.body,~~a.left+(m.scrollX||m.pageXOffset),~~a.top+(m.scrollY||m.pageYOffset))}function f(a,b){if(void 0!==a){if(!0===x(a)){if("number"==typeof a&&void 0===b)throw new SyntaxError("Value could not be converted");return void s.elementScroll.call(this,void 0===a.left?"object"==typeof a?this.scrollLeft:~~a:~~a.left,void 0===a.top?void 0===b?this.scrollTop:~~b:~~a.top)}var c=a,d=c.left,e=void 0===d?this.scrollLeft:d,f=c.top,g=void 0===f?this.scrollTop:f;E.call(this,this,~~e,~~g)}}function g(a,b){return void 0===a?void 0:!0===x(a)?void s.elementScroll.call(this,void 0===a.left?~~a+this.scrollLeft:~~a.left+this.scrollLeft,void 0===a.top?~~b+this.scrollTop:~~a.top+this.scrollTop):void this.scroll({left:~~a.left+this.scrollLeft,top:~~a.top+this.scrollTop,behavior:a.behavior})}var h=void 0===a?{}:a,i=h.force,j=h.duration,k=void 0===j?468:j,l=h.win,m=void 0===l?window:l,n=h.doc,o=void 0===n?document:n;if(!("scrollBehavior"in o.documentElement.style&&!0!==(void 0!==i&&i))){var p,q=~~k,r=function(a,b){this.scrollLeft=a,this.scrollTop=b},s={scroll:m.scroll||m.scrollTo,scrollBy:m.scrollBy,elementScroll:m.Element.prototype.scroll||r,scrollIntoView:m.Element.prototype.scrollIntoView},t=m.performance&&m.performance.now?m.performance.now.bind(m.performance):Date.now,u=function(a){return new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(a)},v=u(m.navigator.userAgent)?1:0,w=function(a){var b=Math.cos,c=Math.PI;return .5*(1-b(c*a))},x=function(a){if(null===a||"object"!=typeof a||void 0===a.behavior||"auto"===a.behavior)return!0;if("object"==typeof a&&"smooth"===a.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+a.behavior+" is not a valid value for enumeration ScrollBehavior.")},y=function(a,b){return"Y"===b?a.clientHeight+v<a.scrollHeight:"X"===b&&a.clientWidth+v<a.scrollWidth},z=function(a,b){var c=m.getComputedStyle(a,null)["overflow"+b];return"auto"===c||"scroll"===c},A=function(a){var b=y(a,"Y")&&z(a,"Y"),c=y(a,"X")&&z(a,"X");return b||c},B=function(a){var b=a;do b=b.parentElement;while(b!==o.body&&!1===A(b));return b},C=function(a){if(!D){var b=t(),c=(b-a.startTime)/q;c=1<c?1:c;var d=w(c),e=a.startX+(a.x-a.startX)*d,f=a.startY+(a.y-a.startY)*d;a.method.call(a.scrollable,e,f),(e!==a.x||f!==a.y)&&m.requestAnimationFrame(C.bind(m,a))}},D=!1,E=function(a,c,d){var e,f,g,h,i=t();a===o.body?(e=m,f=m.scrollX||m.pageXOffset,g=m.scrollY||m.pageYOffset,h=s.scroll):(e=a,f=a.scrollLeft,g=a.scrollTop,h=r),m.addEventListener("wheel",b,{passive:!0,once:!0}),m.addEventListener("touchmove",b,{passive:!0,once:!0}),C({scrollable:e,method:h,startTime:i,startX:f,startY:g,x:c,y:d})};m.scroll=m.scrollTo=d,m.scrollBy=e,m.Element.prototype.scroll=m.Element.prototype.scrollTo=f,m.Element.prototype.scrollBy=g;var F=function(a,b,c,d){var e=0===b&&c||1===b&&!c?a.inline:a.block;return"center"===e?1:"nearest"===e?0:"start"===e?0===b?d?5:4:2:"end"===e?0===b?d?4:5:3:c?0===b?0:2:0===b?4:0};m.Element.prototype.scrollIntoView=function(a){if(void 0===a||!0===a||!1===a||!0===x(a))return void s.scrollIntoView.call(this,void 0===a||a);var b=B(this),c=b.getBoundingClientRect(),d=this.getBoundingClientRect(),e=c.left,f=c.right,g=c.top,h=c.bottom,i=c.height,j=c.width,k=d.left,l=d.right,n=d.top,p=d.bottom,q=d.height,r=d.width,t=m.innerHeight,u=m.innerWidth,v=m.getComputedStyle(this).writingMode,w="horizontal-tb"===v,y="vertical-rl"===v,z=F(a,0,w,y),A=F(a,1,w,y),C=0,D=0,G=0,H=0,I=0,J=0;switch(z){case 4:C=k-e,I=e,G=k;break;case 1:C=k-e+r/2-j/2,I=(e+f-u)/2,G=(k+l-u)/2;break;case 5:C=l-f,I=f-u,G=l-u;break;case 0:{var K=k+C;k<=e&&r<=j||l>=f&&r>=j?(C=k-e,K=e):(k<e&&r>j||l>f&&r<j)&&(C=l-f,K=f-r),0>K&&r<u||K+r>u&&r>u?I=K:(0>K&&r>u||K+r>u&&r<u)&&(I=K+r-u),G=C+I}}switch(A){case 2:D=n-g,J=g,H=n;break;case 1:D=n-g+q/2-i/2,J=(g+h-t)/2,H=(n+p-t)/2;break;case 3:D=p-h,J=h-t,H=p-t;break;case 0:{var K=n+D;n<=g&&q<=i||p>=h&&q>=i?(D=n-g,K=g):(n<g&&q>i||p>h&&q<i)&&(D=p-h,K=h-q),0>K&&q<=t||K+q>t&&q>t?J=K:(0>K&&q>t||K+q>=t&&q<=t)&&(J=K+q-t),H=D+J}}b===o.body?m.scrollBy({left:G,top:H,behavior:"smooth"}):(E.call(this,b,b.scrollLeft+C,b.scrollTop+D),"fixed"!==m.getComputedStyle(b).position&&m.scrollBy({left:I,top:J,behavior:"smooth"}))}}},b="undefined"!=typeof document&&(document.currentScript||document.querySelector("script[data-seamless]"));if(b){var c=b.dataset.polyfill,d=~~b.dataset.duration;d=0<d?d:void 0,a({force:"force"===c,duration:d})}else global.seamless=a})();
//# sourceMappingURL=seamless.browser.min.js.map

67

dist/seamless.esm.js

@@ -1,2 +0,2 @@

const seamless = ({ force = false, duration = 468, win = window, doc = document, } = {}) => {
const seamless = ({ force = false, duration = 468, win = window, doc = document } = {}) => {
// return if scroll behavior is supported and polyfill is not forced

@@ -20,5 +20,3 @@ if ("scrollBehavior" in doc.documentElement.style && force !== true) {

// define timing method
const now = win.performance && win.performance.now
? win.performance.now.bind(win.performance)
: Date.now;
const now = win.performance && win.performance.now ? win.performance.now.bind(win.performance) : Date.now;
const isMicrosoftBrowser = (userAgent) => {

@@ -33,5 +31,3 @@ const userAgentPatterns = ["MSIE ", "Trident/", "Edge/"];

*/
const ROUNDING_TOLERANCE = isMicrosoftBrowser(win.navigator.userAgent)
? 1
: 0;
const ROUNDING_TOLERANCE = isMicrosoftBrowser(win.navigator.userAgent) ? 1 : 0;
const ease = (k) => {

@@ -44,4 +40,3 @@ return 0.5 * (1 - Math.cos(Math.PI * k));

firstArg.behavior === undefined ||
firstArg.behavior === "auto" ||
firstArg.behavior === "instant") {
firstArg.behavior === "auto") {
// first argument is not an object/null

@@ -185,11 +180,3 @@ // or behavior is auto, instant or undefined

if (shouldBailOut(firstArg)) {
original.scrollBy.call(win, firstArg.left !== undefined
? firstArg.left
: typeof firstArg !== "object"
? firstArg
: 0, firstArg.top !== undefined
? firstArg.top
: secondArg !== undefined
? secondArg
: 0);
original.scrollBy.call(win, firstArg.left !== undefined ? firstArg.left : typeof firstArg !== "object" ? firstArg : 0, firstArg.top !== undefined ? firstArg.top : secondArg !== undefined ? secondArg : 0);
return;

@@ -220,10 +207,6 @@ }

// use top prop, second argument or fallback to scrollTop
firstArg.top !== undefined
? ~~firstArg.top
: secondArg !== undefined
? ~~secondArg
: this.scrollTop);
firstArg.top !== undefined ? ~~firstArg.top : secondArg !== undefined ? ~~secondArg : this.scrollTop);
return;
}
const { left = this.scrollLeft, top = this.scrollTop, } = firstArg;
const { left = this.scrollLeft, top = this.scrollTop } = firstArg;
// LET THE SMOOTHNESS BEGIN!

@@ -240,7 +223,3 @@ seamlessScroll.call(this, this, ~~left, ~~top);

if (shouldBailOut(firstArg) === true) {
original.elementScroll.call(this, firstArg.left !== undefined
? ~~firstArg.left + this.scrollLeft
: ~~firstArg + this.scrollLeft, firstArg.top !== undefined
? ~~firstArg.top + this.scrollTop
: ~~secondArg + this.scrollTop);
original.elementScroll.call(this, firstArg.left !== undefined ? ~~firstArg.left + this.scrollLeft : ~~firstArg + this.scrollLeft, firstArg.top !== undefined ? ~~firstArg.top + this.scrollTop : ~~secondArg + this.scrollTop);
return;

@@ -257,4 +236,3 @@ }

const ToPhysicalAlignment = (options, axis, isHorizontalWritingMode, isFlippedBlocksMode) => {
const alignment = (axis === 0 /* HorizontalScroll */ &&
isHorizontalWritingMode) ||
const alignment = (axis === 0 /* HorizontalScroll */ && isHorizontalWritingMode) ||
(axis === 1 /* VerticalScroll */ && !isHorizontalWritingMode)

@@ -296,6 +274,3 @@ ? options.inline

// avoid smooth behavior if not required
if (arg === undefined ||
arg === true ||
arg === false ||
shouldBailOut(arg) === true) {
if (arg === undefined || arg === true || arg === false || shouldBailOut(arg) === true) {
original.scrollIntoView.call(this, arg === undefined ? true : arg);

@@ -341,4 +316,4 @@ return;

let targetStart = clientLeft + cx;
if ((clientLeft < parentLeft && clientWidth < parentWidth) ||
(clientRight > parentRight && clientWidth > parentWidth)) {
if ((clientLeft <= parentLeft && clientWidth <= parentWidth) ||
(clientRight >= parentRight && clientWidth >= parentWidth)) {
cx = clientLeft - parentLeft;

@@ -353,9 +328,7 @@ targetStart = parentLeft;

if ((targetStart < 0 && clientWidth < winInnerWidth) ||
(targetStart + clientWidth > winInnerWidth &&
clientWidth > winInnerWidth)) {
(targetStart + clientWidth > winInnerWidth && clientWidth > winInnerWidth)) {
px = targetStart;
}
else if ((targetStart < 0 && clientWidth > winInnerWidth) ||
(targetStart + clientWidth > winInnerWidth &&
clientWidth < winInnerWidth)) {
(targetStart + clientWidth > winInnerWidth && clientWidth < winInnerWidth)) {
px = targetStart + clientWidth - winInnerWidth;

@@ -386,4 +359,4 @@ }

let targetStart = clientTop + cy;
if ((clientTop < parentTop && clientHeight < parentHeight) ||
(clientBottom > parentBottom && clientHeight > parentHeight)) {
if ((clientTop <= parentTop && clientHeight <= parentHeight) ||
(clientBottom >= parentBottom && clientHeight >= parentHeight)) {
cy = clientTop - parentTop;

@@ -397,10 +370,8 @@ targetStart = parentTop;

}
if ((targetStart < 0 && clientHeight < winInnerHeight) ||
(targetStart + clientHeight > winInnerHeight &&
clientHeight > winInnerHeight)) {
if ((targetStart < 0 && clientHeight <= winInnerHeight) ||
(targetStart + clientHeight > winInnerHeight && clientHeight > winInnerHeight)) {
py = targetStart;
}
else if ((targetStart < 0 && clientHeight > winInnerHeight) ||
(targetStart + clientHeight > winInnerHeight &&
clientHeight < winInnerHeight)) {
(targetStart + clientHeight >= winInnerHeight && clientHeight <= winInnerHeight)) {
py = targetStart + clientHeight - winInnerHeight;

@@ -407,0 +378,0 @@ }

@@ -1,4 +0,2 @@

const seamless=({force:a=!1,duration:b=468,win:c=window,doc:d=document}={})=>{function e(){t=!0,c.clearTimeout(s),s=c.setTimeout(f,g);}function f(){t=!1,c.removeEventListener("wheel",e),c.removeEventListener("touchmove",e);}if("scrollBehavior"in d.documentElement.style&&!0!==a)return;const g=~~b,h=function(a,b){this.scrollLeft=a,this.scrollTop=b;},i={scroll:c.scroll||c.scrollTo,scrollBy:c.scrollBy,elementScroll:c.Element.prototype.scroll||h,scrollIntoView:c.Element.prototype.scrollIntoView},j=c.performance&&c.performance.now?c.performance.now.bind(c.performance):Date.now,k=(a=>{return new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(a)})(c.navigator.userAgent)?1:0,l=a=>.5*(1-Math.cos(Math.PI*a)),m=a=>{if(null===a||"object"!=typeof a||a.behavior===void 0||"auto"===a.behavior||"instant"===a.behavior)return !0;if("object"==typeof a&&"smooth"===a.behavior)return !1;throw new TypeError("behavior member of ScrollOptions "+a.behavior+" is not a valid value for enumeration ScrollBehavior.")},n=(a,b)=>"Y"===b?a.clientHeight+k<a.scrollHeight:"X"===b&&a.clientWidth+k<a.scrollWidth,o=(a,b)=>{const d=c.getComputedStyle(a,null)["overflow"+b];return "auto"===d||"scroll"===d},p=a=>{const b=n(a,"Y")&&o(a,"Y"),c=n(a,"X")&&o(a,"X");return b||c},q=a=>{let b=a;do b=b.parentElement;while(b!==d.body&&!1===p(b));return b},r=a=>{if(t)return;const b=j();let d=(b-a.startTime)/g;d=1<d?1:d;const e=l(d),f=a.startX+(a.x-a.startX)*e,h=a.startY+(a.y-a.startY)*e;a.method.call(a.scrollable,f,h),(f!==a.x||h!==a.y)&&c.requestAnimationFrame(r.bind(c,a));};let s,t=!1;const u=(a,b,f)=>{let g,k,l,m;const n=j();a===d.body?(g=c,k=c.scrollX||c.pageXOffset,l=c.scrollY||c.pageYOffset,m=i.scroll):(g=a,k=a.scrollLeft,l=a.scrollTop,m=h),c.addEventListener("wheel",e,{passive:!0,once:!0}),c.addEventListener("touchmove",e,{passive:!0,once:!0}),r({scrollable:g,method:m,startTime:n,startX:k,startY:l,x:b,y:f});};c.scroll=c.scrollTo=function(a,b){if(void 0!==a){if(!0===m(a))return void i.scroll.call(c,void 0===a.left?"object"==typeof a?c.scrollX||c.pageXOffset:a:a.left,void 0===a.top?void 0===b?c.scrollY||c.pageYOffset:b:a.top);const{left:e=c.scrollX||c.pageXOffset,top:f=c.scrollY||c.pageYOffset}=a;u.call(c,d.body,~~e,~~f);}},c.scrollBy=function(a,b){return void 0===a?void 0:m(a)?void i.scrollBy.call(c,void 0===a.left?"object"==typeof a?0:a:a.left,void 0===a.top?void 0===b?0:b:a.top):void u.call(c,d.body,~~a.left+(c.scrollX||c.pageXOffset),~~a.top+(c.scrollY||c.pageYOffset))},c.Element.prototype.scroll=c.Element.prototype.scrollTo=function(a,b){if(void 0!==a){if(!0===m(a)){if("number"==typeof a&&void 0===b)throw new SyntaxError("Value could not be converted");return void i.elementScroll.call(this,void 0===a.left?"object"==typeof a?this.scrollLeft:~~a:~~a.left,void 0===a.top?void 0===b?this.scrollTop:~~b:~~a.top)}const{left:c=this.scrollLeft,top:d=this.scrollTop}=a;u.call(this,this,~~c,~~d);}},c.Element.prototype.scrollBy=function(a,b){return void 0===a?void 0:!0===m(a)?void i.elementScroll.call(this,void 0===a.left?~~a+this.scrollLeft:~~a.left+this.scrollLeft,void 0===a.top?~~b+this.scrollTop:~~a.top+this.scrollTop):void this.scroll({left:~~a.left+this.scrollLeft,top:~~a.top+this.scrollTop,behavior:a.behavior})};const v=(a,b,c,d)=>{const e=0===b&&c||1===b&&!c?a.inline:a.block;return "center"===e?1:"nearest"===e?0:"start"===e?0===b?d?5:4:2:"end"===e?0===b?d?4:5:3:c?0===b?0:2:0===b?4:0};c.Element.prototype.scrollIntoView=function(a){if(void 0===a||!0===a||!1===a||!0===m(a))return void i.scrollIntoView.call(this,void 0===a||a);const b=q(this),e=b.getBoundingClientRect(),f=this.getBoundingClientRect(),{left:g,right:h,top:j,bottom:k,height:l,width:n}=e,{left:o,right:p,top:r,bottom:s,height:t,width:w}=f,{innerHeight:x,innerWidth:y}=c,{writingMode:z}=c.getComputedStyle(this),A="horizontal-tb"===z,B="vertical-rl"===z,C=v(a,0,A,B),D=v(a,1,A,B);let E=0,F=0,G=0,H=0,I=0,J=0;switch(C){case 4:E=o-g,I=g,G=o;break;case 1:E=o-g+w/2-n/2,I=(g+h-y)/2,G=(o+p-y)/2;break;case 5:E=p-h,I=h-y,G=p-y;break;case 0:{let a=o+E;o<g&&w<n||p>h&&w>n?(E=o-g,a=g):(o<g&&w>n||p>h&&w<n)&&(E=p-h,a=h-w),0>a&&w<y||a+w>y&&w>y?I=a:(0>a&&w>y||a+w>y&&w<y)&&(I=a+w-y),G=E+I;}}switch(D){case 2:F=r-j,J=j,H=r;break;case 1:F=r-j+t/2-l/2,J=(j+k-x)/2,H=(r+s-x)/2;break;case 3:F=s-k,J=k-x,H=s-x;break;case 0:{let a=r+F;r<j&&t<l||s>k&&t>l?(F=r-j,a=j):(r<j&&t>l||s>k&&t<l)&&(F=s-k,a=k-t),0>a&&t<x||a+t>x&&t>x?J=a:(0>a&&t>x||a+t>x&&t<x)&&(J=a+t-x),H=F+J;}}b===d.body?c.scrollBy({left:G,top:H,behavior:"smooth"}):(u.call(this,b,b.scrollLeft+E,b.scrollTop+F),"fixed"!==c.getComputedStyle(b).position&&c.scrollBy({left:I,top:J,behavior:"smooth"}));};};
export { seamless };
const seamless=({force:a=!1,duration:b=468,win:c=window,doc:d=document}={})=>{var g=Math.cos,h=Math.PI;function e(){v=!0,c.clearTimeout(u),u=c.setTimeout(f,i)}function f(){v=!1,c.removeEventListener("wheel",e),c.removeEventListener("touchmove",e)}if("scrollBehavior"in d.documentElement.style&&!0!==a)return;const i=~~b,j=function(a,b){this.scrollLeft=a,this.scrollTop=b},k={scroll:c.scroll||c.scrollTo,scrollBy:c.scrollBy,elementScroll:c.Element.prototype.scroll||j,scrollIntoView:c.Element.prototype.scrollIntoView},l=c.performance&&c.performance.now?c.performance.now.bind(c.performance):Date.now,m=(a=>{return new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(a)})(c.navigator.userAgent)?1:0,n=a=>.5*(1-g(h*a)),o=a=>{if(null===a||"object"!=typeof a||a.behavior===void 0||"auto"===a.behavior)return!0;if("object"==typeof a&&"smooth"===a.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+a.behavior+" is not a valid value for enumeration ScrollBehavior.")},p=(a,b)=>"Y"===b?a.clientHeight+m<a.scrollHeight:"X"===b&&a.clientWidth+m<a.scrollWidth,q=(a,b)=>{const d=c.getComputedStyle(a,null)["overflow"+b];return"auto"===d||"scroll"===d},r=a=>{const b=p(a,"Y")&&q(a,"Y"),c=p(a,"X")&&q(a,"X");return b||c},s=a=>{let b=a;do b=b.parentElement;while(b!==d.body&&!1===r(b));return b},t=a=>{if(v)return;const b=l();let d=(b-a.startTime)/i;d=1<d?1:d;const e=n(d),f=a.startX+(a.x-a.startX)*e,g=a.startY+(a.y-a.startY)*e;a.method.call(a.scrollable,f,g),(f!==a.x||g!==a.y)&&c.requestAnimationFrame(t.bind(c,a))};let u,v=!1;const w=(a,b,f)=>{let g,h,i,m;const n=l();a===d.body?(g=c,h=c.scrollX||c.pageXOffset,i=c.scrollY||c.pageYOffset,m=k.scroll):(g=a,h=a.scrollLeft,i=a.scrollTop,m=j),c.addEventListener("wheel",e,{passive:!0,once:!0}),c.addEventListener("touchmove",e,{passive:!0,once:!0}),t({scrollable:g,method:m,startTime:n,startX:h,startY:i,x:b,y:f})};c.scroll=c.scrollTo=function(a,b){if(void 0!==a){if(!0===o(a))return void k.scroll.call(c,void 0===a.left?"object"==typeof a?c.scrollX||c.pageXOffset:a:a.left,void 0===a.top?void 0===b?c.scrollY||c.pageYOffset:b:a.top);const{left:e=c.scrollX||c.pageXOffset,top:f=c.scrollY||c.pageYOffset}=a;w.call(c,d.body,~~e,~~f)}},c.scrollBy=function(a,b){return void 0===a?void 0:o(a)?void k.scrollBy.call(c,void 0===a.left?"object"==typeof a?0:a:a.left,void 0===a.top?void 0===b?0:b:a.top):void w.call(c,d.body,~~a.left+(c.scrollX||c.pageXOffset),~~a.top+(c.scrollY||c.pageYOffset))},c.Element.prototype.scroll=c.Element.prototype.scrollTo=function(a,b){if(void 0!==a){if(!0===o(a)){if("number"==typeof a&&void 0===b)throw new SyntaxError("Value could not be converted");return void k.elementScroll.call(this,void 0===a.left?"object"==typeof a?this.scrollLeft:~~a:~~a.left,void 0===a.top?void 0===b?this.scrollTop:~~b:~~a.top)}const{left:c=this.scrollLeft,top:d=this.scrollTop}=a;w.call(this,this,~~c,~~d)}},c.Element.prototype.scrollBy=function(a,b){return void 0===a?void 0:!0===o(a)?void k.elementScroll.call(this,void 0===a.left?~~a+this.scrollLeft:~~a.left+this.scrollLeft,void 0===a.top?~~b+this.scrollTop:~~a.top+this.scrollTop):void this.scroll({left:~~a.left+this.scrollLeft,top:~~a.top+this.scrollTop,behavior:a.behavior})};const x=(a,b,c,d)=>{const e=0===b&&c||1===b&&!c?a.inline:a.block;return"center"===e?1:"nearest"===e?0:"start"===e?0===b?d?5:4:2:"end"===e?0===b?d?4:5:3:c?0===b?0:2:0===b?4:0};c.Element.prototype.scrollIntoView=function(a){if(void 0===a||!0===a||!1===a||!0===o(a))return void k.scrollIntoView.call(this,void 0===a||a);const b=s(this),e=b.getBoundingClientRect(),f=this.getBoundingClientRect(),{left:g,right:h,top:i,bottom:j,height:l,width:m}=e,{left:n,right:p,top:q,bottom:r,height:t,width:u}=f,{innerHeight:v,innerWidth:y}=c,{writingMode:z}=c.getComputedStyle(this),A="horizontal-tb"===z,B="vertical-rl"===z,C=x(a,0,A,B),D=x(a,1,A,B);let E=0,F=0,G=0,H=0,I=0,J=0;switch(C){case 4:E=n-g,I=g,G=n;break;case 1:E=n-g+u/2-m/2,I=(g+h-y)/2,G=(n+p-y)/2;break;case 5:E=p-h,I=h-y,G=p-y;break;case 0:{let a=n+E;n<=g&&u<=m||p>=h&&u>=m?(E=n-g,a=g):(n<g&&u>m||p>h&&u<m)&&(E=p-h,a=h-u),0>a&&u<y||a+u>y&&u>y?I=a:(0>a&&u>y||a+u>y&&u<y)&&(I=a+u-y),G=E+I}}switch(D){case 2:F=q-i,J=i,H=q;break;case 1:F=q-i+t/2-l/2,J=(i+j-v)/2,H=(q+r-v)/2;break;case 3:F=r-j,J=j-v,H=r-v;break;case 0:{let a=q+F;q<=i&&t<=l||r>=j&&t>=l?(F=q-i,a=i):(q<i&&t>l||r>j&&t<l)&&(F=r-j,a=j-t),0>a&&t<=v||a+t>v&&t>v?J=a:(0>a&&t>v||a+t>=v&&t<=v)&&(J=a+t-v),H=F+J}}b===d.body?c.scrollBy({left:G,top:H,behavior:"smooth"}):(w.call(this,b,b.scrollLeft+E,b.scrollTop+F),"fixed"!==c.getComputedStyle(b).position&&c.scrollBy({left:I,top:J,behavior:"smooth"}))}};export{seamless};
//# sourceMappingURL=seamless.esm.min.js.map
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.seamless = {})));
}(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.seamless = {}));
}(this, function (exports) { 'use strict';
const seamless = ({ force = false, duration = 468, win = window, doc = document, } = {}) => {
// return if scroll behavior is supported and polyfill is not forced
if ("scrollBehavior" in doc.documentElement.style && force !== true) {
return;
}
// globals
const SCROLL_TIME = ~~duration;
const scrollElement = function (x, y) {
this.scrollLeft = x;
this.scrollTop = y;
};
// object gathering original scroll methods
const original = {
scroll: win.scroll || win.scrollTo,
scrollBy: win.scrollBy,
elementScroll: win.Element.prototype.scroll || scrollElement,
scrollIntoView: win.Element.prototype.scrollIntoView,
};
// define timing method
const now = win.performance && win.performance.now
? win.performance.now.bind(win.performance)
: Date.now;
const isMicrosoftBrowser = (userAgent) => {
const userAgentPatterns = ["MSIE ", "Trident/", "Edge/"];
return new RegExp(userAgentPatterns.join("|")).test(userAgent);
};
/*
* IE has rounding bug rounding down clientHeight and clientWidth and
* rounding up scrollHeight and scrollWidth causing false positives
* on hasScrollableSpace
*/
const ROUNDING_TOLERANCE = isMicrosoftBrowser(win.navigator.userAgent)
? 1
: 0;
const ease = (k) => {
return 0.5 * (1 - Math.cos(Math.PI * k));
};
const shouldBailOut = (firstArg) => {
if (firstArg === null ||
typeof firstArg !== "object" ||
firstArg.behavior === undefined ||
firstArg.behavior === "auto" ||
firstArg.behavior === "instant") {
// first argument is not an object/null
// or behavior is auto, instant or undefined
return true;
}
if (typeof firstArg === "object" && firstArg.behavior === "smooth") {
// first argument is an object and behavior is smooth
return false;
}
// throw error when behavior is not supported
throw new TypeError("behavior member of ScrollOptions " +
firstArg.behavior +
" is not a valid value for enumeration ScrollBehavior.");
};
const hasScrollableSpace = (el, axis) => {
if (axis === "Y") {
return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
}
if (axis === "X") {
return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
}
return false;
};
const canOverflow = (el, axis) => {
const overflowValue = win.getComputedStyle(el, null)[("overflow" + axis)];
return overflowValue === "auto" || overflowValue === "scroll";
};
const isScrollable = (el) => {
const isScrollableY = hasScrollableSpace(el, "Y") && canOverflow(el, "Y");
const isScrollableX = hasScrollableSpace(el, "X") && canOverflow(el, "X");
return isScrollableY || isScrollableX;
};
const findScrollableParent = (el) => {
let parent = el;
do {
parent = parent.parentElement;
} while (parent !== doc.body && isScrollable(parent) === false);
return parent;
};
const step = (context) => {
if (userInterrupt) {
return;
}
const time = now();
let elapsed = (time - context.startTime) / SCROLL_TIME;
// avoid elapsed times higher than one
elapsed = elapsed > 1 ? 1 : elapsed;
// apply easing to elapsed time
const value = ease(elapsed);
const currentX = context.startX + (context.x - context.startX) * value;
const currentY = context.startY + (context.y - context.startY) * value;
context.method.call(context.scrollable, currentX, currentY);
// scroll more if we have not reached our destination
if (currentX !== context.x || currentY !== context.y) {
win.requestAnimationFrame(step.bind(win, context));
}
};
let userInterrupt = false;
let timeOutHandler;
function userIsScrilling() {
userInterrupt = true;
win.clearTimeout(timeOutHandler);
timeOutHandler = win.setTimeout(userEndScroll, SCROLL_TIME);
}
function userEndScroll() {
userInterrupt = false;
win.removeEventListener("wheel", userIsScrilling);
win.removeEventListener("touchmove", userIsScrilling);
}
const seamlessScroll = (el, x, y) => {
let scrollable;
let startX;
let startY;
let method;
const startTime = now();
// define scroll context
if (el === doc.body) {
scrollable = win;
startX = win.scrollX || win.pageXOffset;
startY = win.scrollY || win.pageYOffset;
method = original.scroll;
}
else {
scrollable = el;
startX = el.scrollLeft;
startY = el.scrollTop;
method = scrollElement;
}
win.addEventListener("wheel", userIsScrilling, {
passive: true,
once: true,
});
win.addEventListener("touchmove", userIsScrilling, {
passive: true,
once: true,
});
// scroll looping over a frame
step({
scrollable,
method,
startTime,
startX,
startY,
x,
y,
});
};
function winScrollTo(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg) === true) {
original.scroll.call(win, firstArg.left !== undefined
? firstArg.left
: typeof firstArg !== "object"
? firstArg
: win.scrollX || win.pageXOffset,
// use top prop, second argument if present or fallback to scrollY
firstArg.top !== undefined
? firstArg.top
: secondArg !== undefined
? secondArg
: win.scrollY || win.pageYOffset);
return;
}
const { left = win.scrollX || win.pageXOffset, top = win.scrollY || win.pageYOffset, } = firstArg;
// LET THE SMOOTHNESS BEGIN!
seamlessScroll.call(win, doc.body, ~~left, ~~top);
}
win.scroll = win.scrollTo = winScrollTo;
function winScrollBy(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg)) {
original.scrollBy.call(win, firstArg.left !== undefined
? firstArg.left
: typeof firstArg !== "object"
? firstArg
: 0, firstArg.top !== undefined
? firstArg.top
: secondArg !== undefined
? secondArg
: 0);
return;
}
// LET THE SMOOTHNESS BEGIN!
seamlessScroll.call(win, doc.body, ~~firstArg.left + (win.scrollX || win.pageXOffset), ~~firstArg.top + (win.scrollY || win.pageYOffset));
}
win.scrollBy = winScrollBy;
function eleScrollTo(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg) === true) {
// if one number is passed, throw error to match Firefox implementation
if (typeof firstArg === "number" && secondArg === undefined) {
throw new SyntaxError("Value could not be converted");
}
original.elementScroll.call(this,
// use left prop, first number argument or fallback to scrollLeft
firstArg.left !== undefined
? ~~firstArg.left
: typeof firstArg !== "object"
? ~~firstArg
: this.scrollLeft,
// use top prop, second argument or fallback to scrollTop
firstArg.top !== undefined
? ~~firstArg.top
: secondArg !== undefined
? ~~secondArg
: this.scrollTop);
return;
}
const { left = this.scrollLeft, top = this.scrollTop, } = firstArg;
// LET THE SMOOTHNESS BEGIN!
seamlessScroll.call(this, this, ~~left, ~~top);
}
win.Element.prototype.scroll = win.Element.prototype.scrollTo = eleScrollTo;
function eleScrollBy(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg) === true) {
original.elementScroll.call(this, firstArg.left !== undefined
? ~~firstArg.left + this.scrollLeft
: ~~firstArg + this.scrollLeft, firstArg.top !== undefined
? ~~firstArg.top + this.scrollTop
: ~~secondArg + this.scrollTop);
return;
}
this.scroll({
left: ~~firstArg.left + this.scrollLeft,
top: ~~firstArg.top + this.scrollTop,
behavior: firstArg.behavior,
});
}
win.Element.prototype.scrollBy = eleScrollBy;
// https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/dom/element.cc?l=498-532&rcl=b0f7ee7dfea5ecef6850808aefd4beebc753bd06
const ToPhysicalAlignment = (options, axis, isHorizontalWritingMode, isFlippedBlocksMode) => {
const alignment = (axis === 0 /* HorizontalScroll */ &&
isHorizontalWritingMode) ||
(axis === 1 /* VerticalScroll */ && !isHorizontalWritingMode)
? options.inline
: options.block;
if (alignment === "center") {
return 1 /* AlignCenterAlways */;
}
if (alignment === "nearest") {
return 0 /* AlignToEdgeIfNeeded */;
}
if (alignment === "start") {
return axis === 0 /* HorizontalScroll */
? isFlippedBlocksMode
? 5 /* AlignRightAlways */
: 4 /* AlignLeftAlways */
: 2 /* AlignTopAlways */;
}
if (alignment === "end") {
return axis === 0 /* HorizontalScroll */
? isFlippedBlocksMode
? 4 /* AlignLeftAlways */
: 5 /* AlignRightAlways */
: 3 /* AlignBottomAlways */;
}
// Default values
if (isHorizontalWritingMode) {
return axis === 0 /* HorizontalScroll */
? 0 /* AlignToEdgeIfNeeded */
: 2 /* AlignTopAlways */;
}
return axis === 0 /* HorizontalScroll */
? 4 /* AlignLeftAlways */
: 0 /* AlignToEdgeIfNeeded */;
};
// Element.prototype.scrollIntoView
win.Element.prototype.scrollIntoView = function (arg) {
// avoid smooth behavior if not required
if (arg === undefined ||
arg === true ||
arg === false ||
shouldBailOut(arg) === true) {
original.scrollIntoView.call(this, arg === undefined ? true : arg);
return;
}
// LET THE SMOOTHNESS BEGIN!
const scrollableParent = findScrollableParent(this);
const parentRects = scrollableParent.getBoundingClientRect();
const clientRects = this.getBoundingClientRect();
const { left: parentLeft, right: parentRight, top: parentTop, bottom: parentBottom, height: parentHeight, width: parentWidth, } = parentRects;
const { left: clientLeft, right: clientRight, top: clientTop, bottom: clientBottom, height: clientHeight, width: clientWidth, } = clientRects;
const { innerHeight: winInnerHeight, innerWidth: winInnerWidth } = win;
const { writingMode } = win.getComputedStyle(this);
const isHorizontalWritingMode = writingMode === "horizontal-tb";
const isFlippedBlocksWritingMode = writingMode === "vertical-rl";
const alignX = ToPhysicalAlignment(arg, 0 /* HorizontalScroll */, isHorizontalWritingMode, isFlippedBlocksWritingMode);
const alignY = ToPhysicalAlignment(arg, 1 /* VerticalScroll */, isHorizontalWritingMode, isFlippedBlocksWritingMode);
let cx = 0;
let cy = 0;
let dx = 0;
let dy = 0;
let px = 0;
let py = 0;
switch (alignX) {
case 4 /* AlignLeftAlways */:
cx = clientLeft - parentLeft;
px = parentLeft;
dx = clientLeft;
break;
case 1 /* AlignCenterAlways */:
cx = clientLeft - parentLeft + clientWidth / 2 - parentWidth / 2;
px = (parentLeft + parentRight - winInnerWidth) / 2;
dx = (clientLeft + clientRight - winInnerWidth) / 2;
break;
case 5 /* AlignRightAlways */:
cx = clientRight - parentRight;
px = parentRight - winInnerWidth;
dx = clientRight - winInnerWidth;
break;
case 0 /* AlignToEdgeIfNeeded */:
{
let targetStart = clientLeft + cx;
if ((clientLeft < parentLeft && clientWidth < parentWidth) ||
(clientRight > parentRight && clientWidth > parentWidth)) {
cx = clientLeft - parentLeft;
targetStart = parentLeft;
}
else if ((clientLeft < parentLeft && clientWidth > parentWidth) ||
(clientRight > parentRight && clientWidth < parentWidth)) {
cx = clientRight - parentRight;
targetStart = parentRight - clientWidth;
}
if ((targetStart < 0 && clientWidth < winInnerWidth) ||
(targetStart + clientWidth > winInnerWidth &&
clientWidth > winInnerWidth)) {
px = targetStart;
}
else if ((targetStart < 0 && clientWidth > winInnerWidth) ||
(targetStart + clientWidth > winInnerWidth &&
clientWidth < winInnerWidth)) {
px = targetStart + clientWidth - winInnerWidth;
}
dx = cx + px;
}
break;
}
switch (alignY) {
case 2 /* AlignTopAlways */:
cy = clientTop - parentTop;
py = parentTop;
dy = clientTop;
break;
case 1 /* AlignCenterAlways */:
cy = clientTop - parentTop + clientHeight / 2 - parentHeight / 2;
py = (parentTop + parentBottom - winInnerHeight) / 2;
dy = (clientTop + clientBottom - winInnerHeight) / 2;
break;
case 3 /* AlignBottomAlways */:
cy = clientBottom - parentBottom;
py = parentBottom - winInnerHeight;
dy = clientBottom - winInnerHeight;
break;
case 0 /* AlignToEdgeIfNeeded */:
{
let targetStart = clientTop + cy;
if ((clientTop < parentTop && clientHeight < parentHeight) ||
(clientBottom > parentBottom && clientHeight > parentHeight)) {
cy = clientTop - parentTop;
targetStart = parentTop;
}
else if ((clientTop < parentTop && clientHeight > parentHeight) ||
(clientBottom > parentBottom && clientHeight < parentHeight)) {
cy = clientBottom - parentBottom;
targetStart = parentBottom - clientHeight;
}
if ((targetStart < 0 && clientHeight < winInnerHeight) ||
(targetStart + clientHeight > winInnerHeight &&
clientHeight > winInnerHeight)) {
py = targetStart;
}
else if ((targetStart < 0 && clientHeight > winInnerHeight) ||
(targetStart + clientHeight > winInnerHeight &&
clientHeight < winInnerHeight)) {
py = targetStart + clientHeight - winInnerHeight;
}
dy = cy + py;
}
break;
}
if (scrollableParent !== doc.body) {
// reveal element inside parent
seamlessScroll.call(this, scrollableParent, scrollableParent.scrollLeft + cx, scrollableParent.scrollTop + cy);
// reveal parent in viewport unless is fixed
if (win.getComputedStyle(scrollableParent).position !== "fixed") {
win.scrollBy({
left: px,
top: py,
behavior: "smooth",
});
}
}
else {
// reveal element in viewport
win.scrollBy({
left: dx,
top: dy,
behavior: "smooth",
});
}
};
};
const seamless = ({ force = false, duration = 468, win = window, doc = document } = {}) => {
// return if scroll behavior is supported and polyfill is not forced
if ("scrollBehavior" in doc.documentElement.style && force !== true) {
return;
}
// globals
const SCROLL_TIME = ~~duration;
const scrollElement = function (x, y) {
this.scrollLeft = x;
this.scrollTop = y;
};
// object gathering original scroll methods
const original = {
scroll: win.scroll || win.scrollTo,
scrollBy: win.scrollBy,
elementScroll: win.Element.prototype.scroll || scrollElement,
scrollIntoView: win.Element.prototype.scrollIntoView,
};
// define timing method
const now = win.performance && win.performance.now ? win.performance.now.bind(win.performance) : Date.now;
const isMicrosoftBrowser = (userAgent) => {
const userAgentPatterns = ["MSIE ", "Trident/", "Edge/"];
return new RegExp(userAgentPatterns.join("|")).test(userAgent);
};
/*
* IE has rounding bug rounding down clientHeight and clientWidth and
* rounding up scrollHeight and scrollWidth causing false positives
* on hasScrollableSpace
*/
const ROUNDING_TOLERANCE = isMicrosoftBrowser(win.navigator.userAgent) ? 1 : 0;
const ease = (k) => {
return 0.5 * (1 - Math.cos(Math.PI * k));
};
const shouldBailOut = (firstArg) => {
if (firstArg === null ||
typeof firstArg !== "object" ||
firstArg.behavior === undefined ||
firstArg.behavior === "auto") {
// first argument is not an object/null
// or behavior is auto, instant or undefined
return true;
}
if (typeof firstArg === "object" && firstArg.behavior === "smooth") {
// first argument is an object and behavior is smooth
return false;
}
// throw error when behavior is not supported
throw new TypeError("behavior member of ScrollOptions " +
firstArg.behavior +
" is not a valid value for enumeration ScrollBehavior.");
};
const hasScrollableSpace = (el, axis) => {
if (axis === "Y") {
return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
}
if (axis === "X") {
return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
}
return false;
};
const canOverflow = (el, axis) => {
const overflowValue = win.getComputedStyle(el, null)[("overflow" + axis)];
return overflowValue === "auto" || overflowValue === "scroll";
};
const isScrollable = (el) => {
const isScrollableY = hasScrollableSpace(el, "Y") && canOverflow(el, "Y");
const isScrollableX = hasScrollableSpace(el, "X") && canOverflow(el, "X");
return isScrollableY || isScrollableX;
};
const findScrollableParent = (el) => {
let parent = el;
do {
parent = parent.parentElement;
} while (parent !== doc.body && isScrollable(parent) === false);
return parent;
};
const step = (context) => {
if (userInterrupt) {
return;
}
const time = now();
let elapsed = (time - context.startTime) / SCROLL_TIME;
// avoid elapsed times higher than one
elapsed = elapsed > 1 ? 1 : elapsed;
// apply easing to elapsed time
const value = ease(elapsed);
const currentX = context.startX + (context.x - context.startX) * value;
const currentY = context.startY + (context.y - context.startY) * value;
context.method.call(context.scrollable, currentX, currentY);
// scroll more if we have not reached our destination
if (currentX !== context.x || currentY !== context.y) {
win.requestAnimationFrame(step.bind(win, context));
}
};
let userInterrupt = false;
let timeOutHandler;
function userIsScrilling() {
userInterrupt = true;
win.clearTimeout(timeOutHandler);
timeOutHandler = win.setTimeout(userEndScroll, SCROLL_TIME);
}
function userEndScroll() {
userInterrupt = false;
win.removeEventListener("wheel", userIsScrilling);
win.removeEventListener("touchmove", userIsScrilling);
}
const seamlessScroll = (el, x, y) => {
let scrollable;
let startX;
let startY;
let method;
const startTime = now();
// define scroll context
if (el === doc.body) {
scrollable = win;
startX = win.scrollX || win.pageXOffset;
startY = win.scrollY || win.pageYOffset;
method = original.scroll;
}
else {
scrollable = el;
startX = el.scrollLeft;
startY = el.scrollTop;
method = scrollElement;
}
win.addEventListener("wheel", userIsScrilling, {
passive: true,
once: true,
});
win.addEventListener("touchmove", userIsScrilling, {
passive: true,
once: true,
});
// scroll looping over a frame
step({
scrollable,
method,
startTime,
startX,
startY,
x,
y,
});
};
function winScrollTo(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg) === true) {
original.scroll.call(win, firstArg.left !== undefined
? firstArg.left
: typeof firstArg !== "object"
? firstArg
: win.scrollX || win.pageXOffset,
// use top prop, second argument if present or fallback to scrollY
firstArg.top !== undefined
? firstArg.top
: secondArg !== undefined
? secondArg
: win.scrollY || win.pageYOffset);
return;
}
const { left = win.scrollX || win.pageXOffset, top = win.scrollY || win.pageYOffset, } = firstArg;
// LET THE SMOOTHNESS BEGIN!
seamlessScroll.call(win, doc.body, ~~left, ~~top);
}
win.scroll = win.scrollTo = winScrollTo;
function winScrollBy(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg)) {
original.scrollBy.call(win, firstArg.left !== undefined ? firstArg.left : typeof firstArg !== "object" ? firstArg : 0, firstArg.top !== undefined ? firstArg.top : secondArg !== undefined ? secondArg : 0);
return;
}
// LET THE SMOOTHNESS BEGIN!
seamlessScroll.call(win, doc.body, ~~firstArg.left + (win.scrollX || win.pageXOffset), ~~firstArg.top + (win.scrollY || win.pageYOffset));
}
win.scrollBy = winScrollBy;
function eleScrollTo(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg) === true) {
// if one number is passed, throw error to match Firefox implementation
if (typeof firstArg === "number" && secondArg === undefined) {
throw new SyntaxError("Value could not be converted");
}
original.elementScroll.call(this,
// use left prop, first number argument or fallback to scrollLeft
firstArg.left !== undefined
? ~~firstArg.left
: typeof firstArg !== "object"
? ~~firstArg
: this.scrollLeft,
// use top prop, second argument or fallback to scrollTop
firstArg.top !== undefined ? ~~firstArg.top : secondArg !== undefined ? ~~secondArg : this.scrollTop);
return;
}
const { left = this.scrollLeft, top = this.scrollTop } = firstArg;
// LET THE SMOOTHNESS BEGIN!
seamlessScroll.call(this, this, ~~left, ~~top);
}
win.Element.prototype.scroll = win.Element.prototype.scrollTo = eleScrollTo;
function eleScrollBy(firstArg, secondArg) {
// avoid action when no arguments are passed
if (firstArg === undefined) {
return;
}
// avoid smooth behavior if not required
if (shouldBailOut(firstArg) === true) {
original.elementScroll.call(this, firstArg.left !== undefined ? ~~firstArg.left + this.scrollLeft : ~~firstArg + this.scrollLeft, firstArg.top !== undefined ? ~~firstArg.top + this.scrollTop : ~~secondArg + this.scrollTop);
return;
}
this.scroll({
left: ~~firstArg.left + this.scrollLeft,
top: ~~firstArg.top + this.scrollTop,
behavior: firstArg.behavior,
});
}
win.Element.prototype.scrollBy = eleScrollBy;
// https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/dom/element.cc?l=498-532&rcl=b0f7ee7dfea5ecef6850808aefd4beebc753bd06
const ToPhysicalAlignment = (options, axis, isHorizontalWritingMode, isFlippedBlocksMode) => {
const alignment = (axis === 0 /* HorizontalScroll */ && isHorizontalWritingMode) ||
(axis === 1 /* VerticalScroll */ && !isHorizontalWritingMode)
? options.inline
: options.block;
if (alignment === "center") {
return 1 /* AlignCenterAlways */;
}
if (alignment === "nearest") {
return 0 /* AlignToEdgeIfNeeded */;
}
if (alignment === "start") {
return axis === 0 /* HorizontalScroll */
? isFlippedBlocksMode
? 5 /* AlignRightAlways */
: 4 /* AlignLeftAlways */
: 2 /* AlignTopAlways */;
}
if (alignment === "end") {
return axis === 0 /* HorizontalScroll */
? isFlippedBlocksMode
? 4 /* AlignLeftAlways */
: 5 /* AlignRightAlways */
: 3 /* AlignBottomAlways */;
}
// Default values
if (isHorizontalWritingMode) {
return axis === 0 /* HorizontalScroll */
? 0 /* AlignToEdgeIfNeeded */
: 2 /* AlignTopAlways */;
}
return axis === 0 /* HorizontalScroll */
? 4 /* AlignLeftAlways */
: 0 /* AlignToEdgeIfNeeded */;
};
// Element.prototype.scrollIntoView
win.Element.prototype.scrollIntoView = function (arg) {
// avoid smooth behavior if not required
if (arg === undefined || arg === true || arg === false || shouldBailOut(arg) === true) {
original.scrollIntoView.call(this, arg === undefined ? true : arg);
return;
}
// LET THE SMOOTHNESS BEGIN!
const scrollableParent = findScrollableParent(this);
const parentRects = scrollableParent.getBoundingClientRect();
const clientRects = this.getBoundingClientRect();
const { left: parentLeft, right: parentRight, top: parentTop, bottom: parentBottom, height: parentHeight, width: parentWidth, } = parentRects;
const { left: clientLeft, right: clientRight, top: clientTop, bottom: clientBottom, height: clientHeight, width: clientWidth, } = clientRects;
const { innerHeight: winInnerHeight, innerWidth: winInnerWidth } = win;
const { writingMode } = win.getComputedStyle(this);
const isHorizontalWritingMode = writingMode === "horizontal-tb";
const isFlippedBlocksWritingMode = writingMode === "vertical-rl";
const alignX = ToPhysicalAlignment(arg, 0 /* HorizontalScroll */, isHorizontalWritingMode, isFlippedBlocksWritingMode);
const alignY = ToPhysicalAlignment(arg, 1 /* VerticalScroll */, isHorizontalWritingMode, isFlippedBlocksWritingMode);
let cx = 0;
let cy = 0;
let dx = 0;
let dy = 0;
let px = 0;
let py = 0;
switch (alignX) {
case 4 /* AlignLeftAlways */:
cx = clientLeft - parentLeft;
px = parentLeft;
dx = clientLeft;
break;
case 1 /* AlignCenterAlways */:
cx = clientLeft - parentLeft + clientWidth / 2 - parentWidth / 2;
px = (parentLeft + parentRight - winInnerWidth) / 2;
dx = (clientLeft + clientRight - winInnerWidth) / 2;
break;
case 5 /* AlignRightAlways */:
cx = clientRight - parentRight;
px = parentRight - winInnerWidth;
dx = clientRight - winInnerWidth;
break;
case 0 /* AlignToEdgeIfNeeded */:
{
let targetStart = clientLeft + cx;
if ((clientLeft <= parentLeft && clientWidth <= parentWidth) ||
(clientRight >= parentRight && clientWidth >= parentWidth)) {
cx = clientLeft - parentLeft;
targetStart = parentLeft;
}
else if ((clientLeft < parentLeft && clientWidth > parentWidth) ||
(clientRight > parentRight && clientWidth < parentWidth)) {
cx = clientRight - parentRight;
targetStart = parentRight - clientWidth;
}
if ((targetStart < 0 && clientWidth < winInnerWidth) ||
(targetStart + clientWidth > winInnerWidth && clientWidth > winInnerWidth)) {
px = targetStart;
}
else if ((targetStart < 0 && clientWidth > winInnerWidth) ||
(targetStart + clientWidth > winInnerWidth && clientWidth < winInnerWidth)) {
px = targetStart + clientWidth - winInnerWidth;
}
dx = cx + px;
}
break;
}
switch (alignY) {
case 2 /* AlignTopAlways */:
cy = clientTop - parentTop;
py = parentTop;
dy = clientTop;
break;
case 1 /* AlignCenterAlways */:
cy = clientTop - parentTop + clientHeight / 2 - parentHeight / 2;
py = (parentTop + parentBottom - winInnerHeight) / 2;
dy = (clientTop + clientBottom - winInnerHeight) / 2;
break;
case 3 /* AlignBottomAlways */:
cy = clientBottom - parentBottom;
py = parentBottom - winInnerHeight;
dy = clientBottom - winInnerHeight;
break;
case 0 /* AlignToEdgeIfNeeded */:
{
let targetStart = clientTop + cy;
if ((clientTop <= parentTop && clientHeight <= parentHeight) ||
(clientBottom >= parentBottom && clientHeight >= parentHeight)) {
cy = clientTop - parentTop;
targetStart = parentTop;
}
else if ((clientTop < parentTop && clientHeight > parentHeight) ||
(clientBottom > parentBottom && clientHeight < parentHeight)) {
cy = clientBottom - parentBottom;
targetStart = parentBottom - clientHeight;
}
if ((targetStart < 0 && clientHeight <= winInnerHeight) ||
(targetStart + clientHeight > winInnerHeight && clientHeight > winInnerHeight)) {
py = targetStart;
}
else if ((targetStart < 0 && clientHeight > winInnerHeight) ||
(targetStart + clientHeight >= winInnerHeight && clientHeight <= winInnerHeight)) {
py = targetStart + clientHeight - winInnerHeight;
}
dy = cy + py;
}
break;
}
if (scrollableParent !== doc.body) {
// reveal element inside parent
seamlessScroll.call(this, scrollableParent, scrollableParent.scrollLeft + cx, scrollableParent.scrollTop + cy);
// reveal parent in viewport unless is fixed
if (win.getComputedStyle(scrollableParent).position !== "fixed") {
win.scrollBy({
left: px,
top: py,
behavior: "smooth",
});
}
}
else {
// reveal element in viewport
win.scrollBy({
left: dx,
top: dy,
behavior: "smooth",
});
}
};
};
exports.seamless = seamless;
exports.seamless = seamless;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));
//# sourceMappingURL=seamless.js.map

@@ -1,14 +0,2 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.seamless = {})));
}(this, (function (exports) { 'use strict';
const seamless=({force:a=!1,duration:b=468,win:c=window,doc:d=document}={})=>{function e(){t=!0,c.clearTimeout(s),s=c.setTimeout(f,g);}function f(){t=!1,c.removeEventListener("wheel",e),c.removeEventListener("touchmove",e);}if("scrollBehavior"in d.documentElement.style&&!0!==a)return;const g=~~b,h=function(a,b){this.scrollLeft=a,this.scrollTop=b;},i={scroll:c.scroll||c.scrollTo,scrollBy:c.scrollBy,elementScroll:c.Element.prototype.scroll||h,scrollIntoView:c.Element.prototype.scrollIntoView},j=c.performance&&c.performance.now?c.performance.now.bind(c.performance):Date.now,k=(a=>{return new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(a)})(c.navigator.userAgent)?1:0,l=a=>.5*(1-Math.cos(Math.PI*a)),m=a=>{if(null===a||"object"!=typeof a||a.behavior===void 0||"auto"===a.behavior||"instant"===a.behavior)return !0;if("object"==typeof a&&"smooth"===a.behavior)return !1;throw new TypeError("behavior member of ScrollOptions "+a.behavior+" is not a valid value for enumeration ScrollBehavior.")},n=(a,b)=>"Y"===b?a.clientHeight+k<a.scrollHeight:"X"===b&&a.clientWidth+k<a.scrollWidth,o=(a,b)=>{const d=c.getComputedStyle(a,null)["overflow"+b];return "auto"===d||"scroll"===d},p=a=>{const b=n(a,"Y")&&o(a,"Y"),c=n(a,"X")&&o(a,"X");return b||c},q=a=>{let b=a;do b=b.parentElement;while(b!==d.body&&!1===p(b));return b},r=a=>{if(t)return;const b=j();let d=(b-a.startTime)/g;d=1<d?1:d;const e=l(d),f=a.startX+(a.x-a.startX)*e,h=a.startY+(a.y-a.startY)*e;a.method.call(a.scrollable,f,h),(f!==a.x||h!==a.y)&&c.requestAnimationFrame(r.bind(c,a));};let s,t=!1;const u=(a,b,f)=>{let g,k,l,m;const n=j();a===d.body?(g=c,k=c.scrollX||c.pageXOffset,l=c.scrollY||c.pageYOffset,m=i.scroll):(g=a,k=a.scrollLeft,l=a.scrollTop,m=h),c.addEventListener("wheel",e,{passive:!0,once:!0}),c.addEventListener("touchmove",e,{passive:!0,once:!0}),r({scrollable:g,method:m,startTime:n,startX:k,startY:l,x:b,y:f});};c.scroll=c.scrollTo=function(a,b){if(void 0!==a){if(!0===m(a))return void i.scroll.call(c,void 0===a.left?"object"==typeof a?c.scrollX||c.pageXOffset:a:a.left,void 0===a.top?void 0===b?c.scrollY||c.pageYOffset:b:a.top);const{left:e=c.scrollX||c.pageXOffset,top:f=c.scrollY||c.pageYOffset}=a;u.call(c,d.body,~~e,~~f);}},c.scrollBy=function(a,b){return void 0===a?void 0:m(a)?void i.scrollBy.call(c,void 0===a.left?"object"==typeof a?0:a:a.left,void 0===a.top?void 0===b?0:b:a.top):void u.call(c,d.body,~~a.left+(c.scrollX||c.pageXOffset),~~a.top+(c.scrollY||c.pageYOffset))},c.Element.prototype.scroll=c.Element.prototype.scrollTo=function(a,b){if(void 0!==a){if(!0===m(a)){if("number"==typeof a&&void 0===b)throw new SyntaxError("Value could not be converted");return void i.elementScroll.call(this,void 0===a.left?"object"==typeof a?this.scrollLeft:~~a:~~a.left,void 0===a.top?void 0===b?this.scrollTop:~~b:~~a.top)}const{left:c=this.scrollLeft,top:d=this.scrollTop}=a;u.call(this,this,~~c,~~d);}},c.Element.prototype.scrollBy=function(a,b){return void 0===a?void 0:!0===m(a)?void i.elementScroll.call(this,void 0===a.left?~~a+this.scrollLeft:~~a.left+this.scrollLeft,void 0===a.top?~~b+this.scrollTop:~~a.top+this.scrollTop):void this.scroll({left:~~a.left+this.scrollLeft,top:~~a.top+this.scrollTop,behavior:a.behavior})};const v=(a,b,c,d)=>{const e=0===b&&c||1===b&&!c?a.inline:a.block;return "center"===e?1:"nearest"===e?0:"start"===e?0===b?d?5:4:2:"end"===e?0===b?d?4:5:3:c?0===b?0:2:0===b?4:0};c.Element.prototype.scrollIntoView=function(a){if(void 0===a||!0===a||!1===a||!0===m(a))return void i.scrollIntoView.call(this,void 0===a||a);const b=q(this),e=b.getBoundingClientRect(),f=this.getBoundingClientRect(),{left:g,right:h,top:j,bottom:k,height:l,width:n}=e,{left:o,right:p,top:r,bottom:s,height:t,width:w}=f,{innerHeight:x,innerWidth:y}=c,{writingMode:z}=c.getComputedStyle(this),A="horizontal-tb"===z,B="vertical-rl"===z,C=v(a,0,A,B),D=v(a,1,A,B);let E=0,F=0,G=0,H=0,I=0,J=0;switch(C){case 4:E=o-g,I=g,G=o;break;case 1:E=o-g+w/2-n/2,I=(g+h-y)/2,G=(o+p-y)/2;break;case 5:E=p-h,I=h-y,G=p-y;break;case 0:{let a=o+E;o<g&&w<n||p>h&&w>n?(E=o-g,a=g):(o<g&&w>n||p>h&&w<n)&&(E=p-h,a=h-w),0>a&&w<y||a+w>y&&w>y?I=a:(0>a&&w>y||a+w>y&&w<y)&&(I=a+w-y),G=E+I;}}switch(D){case 2:F=r-j,J=j,H=r;break;case 1:F=r-j+t/2-l/2,J=(j+k-x)/2,H=(r+s-x)/2;break;case 3:F=s-k,J=k-x,H=s-x;break;case 0:{let a=r+F;r<j&&t<l||s>k&&t>l?(F=r-j,a=j):(r<j&&t>l||s>k&&t<l)&&(F=s-k,a=k-t),0>a&&t<x||a+t>x&&t>x?J=a:(0>a&&t>x||a+t>x&&t<x)&&(J=a+t-x),H=F+J;}}b===d.body?c.scrollBy({left:G,top:H,behavior:"smooth"}):(u.call(this,b,b.scrollLeft+E,b.scrollTop+F),"fixed"!==c.getComputedStyle(b).position&&c.scrollBy({left:I,top:J,behavior:"smooth"}));};};
exports.seamless = seamless;
Object.defineProperty(exports, '__esModule', { value: true });
})));
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.seamless={}))})(this,function(a){'use strict';var b=Math.cos,c=Math.PI;const d=({force:a=!1,duration:d=468,win:e=window,doc:f=document}={})=>{function g(){v=!0,e.clearTimeout(u),u=e.setTimeout(h,i)}function h(){v=!1,e.removeEventListener("wheel",g),e.removeEventListener("touchmove",g)}if("scrollBehavior"in f.documentElement.style&&!0!==a)return;const i=~~d,j=function(a,b){this.scrollLeft=a,this.scrollTop=b},k={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:e.Element.prototype.scroll||j,scrollIntoView:e.Element.prototype.scrollIntoView},l=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now,m=(a=>{return new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(a)})(e.navigator.userAgent)?1:0,n=a=>.5*(1-b(c*a)),o=a=>{if(null===a||"object"!=typeof a||a.behavior===void 0||"auto"===a.behavior)return!0;if("object"==typeof a&&"smooth"===a.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+a.behavior+" is not a valid value for enumeration ScrollBehavior.")},p=(a,b)=>"Y"===b?a.clientHeight+m<a.scrollHeight:"X"===b&&a.clientWidth+m<a.scrollWidth,q=(a,b)=>{const c=e.getComputedStyle(a,null)["overflow"+b];return"auto"===c||"scroll"===c},r=a=>{const b=p(a,"Y")&&q(a,"Y"),c=p(a,"X")&&q(a,"X");return b||c},s=a=>{let b=a;do b=b.parentElement;while(b!==f.body&&!1===r(b));return b},t=a=>{if(v)return;const b=l();let c=(b-a.startTime)/i;c=1<c?1:c;const d=n(c),f=a.startX+(a.x-a.startX)*d,g=a.startY+(a.y-a.startY)*d;a.method.call(a.scrollable,f,g),(f!==a.x||g!==a.y)&&e.requestAnimationFrame(t.bind(e,a))};let u,v=!1;const w=(a,b,c)=>{let d,h,i,m;const n=l();a===f.body?(d=e,h=e.scrollX||e.pageXOffset,i=e.scrollY||e.pageYOffset,m=k.scroll):(d=a,h=a.scrollLeft,i=a.scrollTop,m=j),e.addEventListener("wheel",g,{passive:!0,once:!0}),e.addEventListener("touchmove",g,{passive:!0,once:!0}),t({scrollable:d,method:m,startTime:n,startX:h,startY:i,x:b,y:c})};e.scroll=e.scrollTo=function(a,b){if(void 0!==a){if(!0===o(a))return void k.scroll.call(e,void 0===a.left?"object"==typeof a?e.scrollX||e.pageXOffset:a:a.left,void 0===a.top?void 0===b?e.scrollY||e.pageYOffset:b:a.top);const{left:c=e.scrollX||e.pageXOffset,top:d=e.scrollY||e.pageYOffset}=a;w.call(e,f.body,~~c,~~d)}},e.scrollBy=function(a,b){return void 0===a?void 0:o(a)?void k.scrollBy.call(e,void 0===a.left?"object"==typeof a?0:a:a.left,void 0===a.top?void 0===b?0:b:a.top):void w.call(e,f.body,~~a.left+(e.scrollX||e.pageXOffset),~~a.top+(e.scrollY||e.pageYOffset))},e.Element.prototype.scroll=e.Element.prototype.scrollTo=function(a,b){if(void 0!==a){if(!0===o(a)){if("number"==typeof a&&void 0===b)throw new SyntaxError("Value could not be converted");return void k.elementScroll.call(this,void 0===a.left?"object"==typeof a?this.scrollLeft:~~a:~~a.left,void 0===a.top?void 0===b?this.scrollTop:~~b:~~a.top)}const{left:c=this.scrollLeft,top:d=this.scrollTop}=a;w.call(this,this,~~c,~~d)}},e.Element.prototype.scrollBy=function(a,b){return void 0===a?void 0:!0===o(a)?void k.elementScroll.call(this,void 0===a.left?~~a+this.scrollLeft:~~a.left+this.scrollLeft,void 0===a.top?~~b+this.scrollTop:~~a.top+this.scrollTop):void this.scroll({left:~~a.left+this.scrollLeft,top:~~a.top+this.scrollTop,behavior:a.behavior})};const x=(a,b,c,d)=>{const e=0===b&&c||1===b&&!c?a.inline:a.block;return"center"===e?1:"nearest"===e?0:"start"===e?0===b?d?5:4:2:"end"===e?0===b?d?4:5:3:c?0===b?0:2:0===b?4:0};e.Element.prototype.scrollIntoView=function(a){if(void 0===a||!0===a||!1===a||!0===o(a))return void k.scrollIntoView.call(this,void 0===a||a);const b=s(this),c=b.getBoundingClientRect(),d=this.getBoundingClientRect(),{left:g,right:h,top:i,bottom:j,height:l,width:m}=c,{left:n,right:p,top:q,bottom:r,height:t,width:u}=d,{innerHeight:v,innerWidth:y}=e,{writingMode:z}=e.getComputedStyle(this),A="horizontal-tb"===z,B="vertical-rl"===z,C=x(a,0,A,B),D=x(a,1,A,B);let E=0,F=0,G=0,H=0,I=0,J=0;switch(C){case 4:E=n-g,I=g,G=n;break;case 1:E=n-g+u/2-m/2,I=(g+h-y)/2,G=(n+p-y)/2;break;case 5:E=p-h,I=h-y,G=p-y;break;case 0:{let a=n+E;n<=g&&u<=m||p>=h&&u>=m?(E=n-g,a=g):(n<g&&u>m||p>h&&u<m)&&(E=p-h,a=h-u),0>a&&u<y||a+u>y&&u>y?I=a:(0>a&&u>y||a+u>y&&u<y)&&(I=a+u-y),G=E+I}}switch(D){case 2:F=q-i,J=i,H=q;break;case 1:F=q-i+t/2-l/2,J=(i+j-v)/2,H=(q+r-v)/2;break;case 3:F=r-j,J=j-v,H=r-v;break;case 0:{let a=q+F;q<=i&&t<=l||r>=j&&t>=l?(F=q-i,a=i):(q<i&&t>l||r>j&&t<l)&&(F=r-j,a=j-t),0>a&&t<=v||a+t>v&&t>v?J=a:(0>a&&t>v||a+t>=v&&t<=v)&&(J=a+t-v),H=F+J}}b===f.body?e.scrollBy({left:G,top:H,behavior:"smooth"}):(w.call(this,b,b.scrollLeft+E,b.scrollTop+F),"fixed"!==e.getComputedStyle(b).position&&e.scrollBy({left:I,top:J,behavior:"smooth"}))}};a.seamless=d,Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=seamless.min.js.map
{
"title": "smoothscroll",
"name": "seamless-scroll-polyfill",
"description": "Smooth Scroll behavior polyfill",
"version": "0.5.3",
"author": {
"name": "Dustan Kasten",
"email": "dustan.kasten@gmail.com",
"url": "https://iamdustan.com"
},
"contributors": [
{
"name": "Jeremias Menichelli",
"email": "jmenichelli@gmail.com",
"url": "https://jeremenichelli.io"
}
],
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.0.0-beta.51",
"ava": "1.0.0-beta.8",
"babel-minify": "^0.4.3",
"babel-preset-minify": "^0.4.3",
"lodash.clonedeep": "^4.5.0",
"prettier": "^1.13.7",
"rollup": "^0.65.0",
"rollup-plugin-babel": "^4.0.0-beta.7",
"rollup-plugin-typescript2": "^0.17.0",
"ts-node": "^7.0.0",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.13.0",
"tslint-plugin-prettier": "^1.3.0",
"typescript": "^3.0.1"
},
"main": "dist/seamless.js",
"umd:main": "dist/seamless.js",
"jsnext:main": "dist/seamless.esm.js",
"module": "dist/seamless.esm.js",
"browser": "dist/seamless.browser.min.js",
"files": [
"dist"
],
"scripts": {
"lint": "tslint {src,test}/**/*.{js,ts}",
"test": "ava -v",
"build": "rollup -c rollup.config.js",
"listdiff": "prettier --list-different {src,test}/**/*.{js,ts}",
"format": "prettier --write {src,test}/**/*.{js,ts}"
},
"repository": {
"type": "git",
"url": "git+https://github.com/magic-akari/seamless-scroll-polyfill.git"
},
"keywords": [
"smooth",
"scroll",
"CSSOM",
"polyfill"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/magic-akari/seamless-scroll-polyfill/issues"
},
"homepage": "https://github.com/magic-akari/seamless-scroll-polyfill"
"title": "smoothscroll",
"name": "seamless-scroll-polyfill",
"description": "Smooth Scroll behavior polyfill",
"version": "0.5.4",
"author": {
"name": "Dustan Kasten",
"email": "dustan.kasten@gmail.com",
"url": "https://iamdustan.com"
},
"contributors": [
{
"name": "Jeremias Menichelli",
"email": "jmenichelli@gmail.com",
"url": "https://jeremenichelli.io"
}
],
"dependencies": {},
"devDependencies": {
"ava": "^1.3.1",
"lodash.clonedeep": "^4.5.0",
"prettier": "^1.16.4",
"rollup": "^1.5.0",
"rollup-plugin-babel-minify": "^7.0.0",
"rollup-plugin-typescript2": "^0.19.3",
"ts-node": "^8.0.3",
"tslint": "^5.13.1",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.3.3333"
},
"main": "dist/seamless.js",
"umd:main": "dist/seamless.js",
"jsnext:main": "dist/seamless.esm.js",
"module": "dist/seamless.esm.js",
"browser": "dist/seamless.browser.min.js",
"files": [
"dist"
],
"scripts": {
"lint": "tslint {src,test}/**/*.{js,ts}",
"test": "ava -v",
"build": "rollup -c rollup.config.js",
"listdiff": "prettier --list-different \"{src,test}/**/*.{js,ts}\" \"./*.{js,json,md}\" \"./*rc\"",
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" \"./*.{js,json,md}\" \"./*rc\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/magic-akari/seamless-scroll-polyfill.git"
},
"keywords": [
"smooth",
"scroll",
"CSSOM",
"polyfill"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/magic-akari/seamless-scroll-polyfill/issues"
},
"homepage": "https://github.com/magic-akari/seamless-scroll-polyfill"
}

@@ -16,3 +16,3 @@ [![Build Status](https://travis-ci.org/magic-akari/seamless-scroll-polyfill.svg?branch=master)](https://travis-ci.org/magic-akari/seamless-scroll-polyfill)

```js
import { seamless } from 'seamless-scroll-polyfill';
import { seamless } from "seamless-scroll-polyfill";

@@ -37,3 +37,3 @@ seamless();

```html
<script src="path/to/seamless.browser.min.js" ></script>
<script src="path/to/seamless.browser.min.js"></script>
```

@@ -72,3 +72,3 @@

```js
import smoothscroll from 'smoothscroll-polyfill';
import smoothscroll from "smoothscroll-polyfill";

@@ -115,14 +115,14 @@ // kick off the polyfill!

* _natively supported in Chrome_
* _natively supported in Firefox_
* Safari 6+
* Internet Explorer 9+
* Microsoft Edge 12+
* Opera Next
- _natively supported in Chrome_
- _natively supported in Firefox_
- Safari 6+
- Internet Explorer 9+
- Microsoft Edge 12+
- Opera Next
## Standards documentation
* http://dev.w3.org/csswg/cssom-view
* http://lists.w3.org/Archives/Public/www-style/2013Mar/0314.html
- http://dev.w3.org/csswg/cssom-view
- http://lists.w3.org/Archives/Public/www-style/2013Mar/0314.html
</blockquote>

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc