smooth-scroll-into-view-if-needed
Advanced tools
Comparing version 1.1.32 to 1.1.33
@@ -11,3 +11,3 @@ { | ||
}, | ||
"version": "1.1.32", | ||
"version": "1.1.33", | ||
"main": "index.js", | ||
@@ -39,24 +39,24 @@ "module": "es/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "7.13.10", | ||
"@babel/core": "7.13.10", | ||
"@babel/plugin-external-helpers": "7.12.13", | ||
"@babel/preset-env": "7.13.12", | ||
"@babel/preset-typescript": "7.13.0", | ||
"@types/jest": "26.0.21", | ||
"@babel/cli": "7.16.0", | ||
"@babel/core": "7.16.0", | ||
"@babel/plugin-external-helpers": "7.16.0", | ||
"@babel/preset-env": "7.16.0", | ||
"@babel/preset-typescript": "7.16.0", | ||
"@types/jest": "26.0.24", | ||
"babel-eslint": "10.1.0", | ||
"babel-plugin-add-module-exports": "1.0.4", | ||
"babel-plugin-dev-expression": "0.2.2", | ||
"concurrently": "6.0.0", | ||
"eslint": "7.22.0", | ||
"eslint-config-prettier": "8.1.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-react": "7.22.0", | ||
"babel-plugin-dev-expression": "0.2.3", | ||
"concurrently": "6.4.0", | ||
"eslint": "7.32.0", | ||
"eslint-config-prettier": "8.3.0", | ||
"eslint-plugin-import": "2.25.3", | ||
"eslint-plugin-react": "7.27.0", | ||
"husky": "5.2.0", | ||
"jest": "26.6.3", | ||
"jest-junit": "12.0.0", | ||
"jest-junit": "12.3.0", | ||
"lint-staged": "10.5.4", | ||
"prettier": "2.2.1", | ||
"prettier-package-json": "2.1.3", | ||
"prettier": "2.4.1", | ||
"prettier-package-json": "2.6.0", | ||
"rimraf": "3.0.2", | ||
"rollup": "2.42.3", | ||
"rollup": "2.60.0", | ||
"rollup-plugin-babel": "4.4.0", | ||
@@ -67,5 +67,5 @@ "rollup-plugin-commonjs": "10.1.0", | ||
"rollup-plugin-terser": "7.0.2", | ||
"semantic-release": "17.4.2", | ||
"ts-jest": "26.5.4", | ||
"typescript": "4.2.3" | ||
"semantic-release": "17.4.7", | ||
"ts-jest": "26.5.6", | ||
"typescript": "4.4.4" | ||
}, | ||
@@ -72,0 +72,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.scrollIntoView = factory()); | ||
}(this, (function () { 'use strict'; | ||
})(this, (function () { 'use strict'; | ||
@@ -57,9 +57,9 @@ function t(t){return "object"==typeof t&&null!=t&&1===t.nodeType}function e(t,e){return (!e||"hidden"!==t)&&"visible"!==t&&"clip"!==t}function n(t,n){if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){var r=getComputedStyle(t,null);return e(r.overflowY,n)||e(r.overflowX,n)||function(t){var e=function(t){if(!t.ownerDocument||!t.ownerDocument.defaultView)return null;try{return t.ownerDocument.defaultView.frameElement}catch(t){return null}}(t);return !!e&&(e.clientHeight<t.scrollHeight||e.clientWidth<t.scrollWidth)}(t)}return !1}function r(t,e,n,r,i,o,l,d){return o<t&&l>e||o>t&&l<e?0:o<=t&&d<=n||l>=e&&d>=n?o-t-r:l>e&&d<n||o<t&&d>n?l-e+i:0}function compute(e,i){var o=window,l=i.scrollMode,d=i.block,u=i.inline,h=i.boundary,a=i.skipOverflowHiddenElements,c="function"==typeof h?h:function(t){return t!==h};if(!t(e))throw new TypeError("Invalid target");for(var f=document.scrollingElement||document.documentElement,s=[],p=e;t(p)&&c(p);){if((p=p.parentElement)===f){s.push(p);break}null!=p&&p===document.body&&n(p)&&!n(document.documentElement)||null!=p&&n(p,a)&&s.push(p);}for(var m=o.visualViewport?o.visualViewport.width:innerWidth,g=o.visualViewport?o.visualViewport.height:innerHeight,w=window.scrollX||pageXOffset,v=window.scrollY||pageYOffset,W=e.getBoundingClientRect(),b=W.height,H=W.width,y=W.top,E=W.right,M=W.bottom,V=W.left,x="start"===d||"nearest"===d?y:"end"===d?M:y+b/2,I="center"===u?V+H/2:"end"===u?E:V,C=[],T=0;T<s.length;T++){var k=s[T],B=k.getBoundingClientRect(),D=B.height,O=B.width,R=B.top,X=B.right,Y=B.bottom,L=B.left;if("if-needed"===l&&y>=0&&V>=0&&M<=g&&E<=m&&y>=R&&M<=Y&&V>=L&&E<=X)return C;var S=getComputedStyle(k),j=parseInt(S.borderLeftWidth,10),q=parseInt(S.borderTopWidth,10),z=parseInt(S.borderRightWidth,10),A=parseInt(S.borderBottomWidth,10),F=0,G=0,J="offsetWidth"in k?k.offsetWidth-k.clientWidth-j-z:0,K="offsetHeight"in k?k.offsetHeight-k.clientHeight-q-A:0;if(f===k)F="start"===d?x:"end"===d?x-g:"nearest"===d?r(v,v+g,g,q,A,v+x,v+x+b,b):x-g/2,G="start"===u?I:"center"===u?I-m/2:"end"===u?I-m:r(w,w+m,m,j,z,w+I,w+I+H,H),F=Math.max(0,F+v),G=Math.max(0,G+w);else {F="start"===d?x-R-q:"end"===d?x-Y+A+K:"nearest"===d?r(R,Y,D,q,A+K,x,x+b,b):x-(R+D/2)+K/2,G="start"===u?I-L-j:"center"===u?I-(L+O/2)+J/2:"end"===u?I-X+z+J:r(L,X,O,j,z+J,I,I+H,H);var N=k.scrollLeft,P=k.scrollTop;x+=P-(F=Math.max(0,Math.min(P+F,k.scrollHeight-D+K))),I+=N-(G=Math.max(0,Math.min(N+G,k.scrollWidth-O+J)));}C.push({el:k,top:F,left:G});}return C} | ||
function scrollIntoView(target, options) { | ||
var targetIsDetached = !target.ownerDocument.documentElement.contains(target); | ||
var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target); | ||
if (isOptionsObject(options) && typeof options.behavior === 'function') { | ||
return options.behavior(targetIsDetached ? [] : compute(target, options)); | ||
return options.behavior(isTargetAttached ? compute(target, options) : []); | ||
} | ||
if (targetIsDetached) { | ||
if (!isTargetAttached) { | ||
return; | ||
@@ -183,2 +183,2 @@ } | ||
}))); | ||
})); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).scrollIntoView=t()}(this,(function(){"use strict";function e(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function t(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function n(e,n){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var r=getComputedStyle(e,null);return t(r.overflowY,n)||t(r.overflowX,n)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function r(e,t,n,r,o,i,l,c){return i<e&&l>t||i>e&&l<t?0:i<=e&&c<=n||l>=t&&c>=n?i-e-r:l>t&&c<n||i<e&&c>n?l-t+o:0}function o(t,o){var i=window,l=o.scrollMode,c=o.block,u=o.inline,a=o.boundary,f=o.skipOverflowHiddenElements,s="function"==typeof a?a:function(e){return e!==a};if(!e(t))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,h=[],m=t;e(m)&&s(m);){if((m=m.parentElement)===d){h.push(m);break}null!=m&&m===document.body&&n(m)&&!n(document.documentElement)||null!=m&&n(m,f)&&h.push(m)}for(var p=i.visualViewport?i.visualViewport.width:innerWidth,v=i.visualViewport?i.visualViewport.height:innerHeight,b=window.scrollX||pageXOffset,w=window.scrollY||pageYOffset,g=t.getBoundingClientRect(),y=g.height,W=g.width,M=g.top,T=g.right,H=g.bottom,x=g.left,E="start"===c||"nearest"===c?M:"end"===c?H:M+y/2,k="center"===u?x+W/2:"end"===u?T:x,V=[],I=0;I<h.length;I++){var L=h[I],X=L.getBoundingClientRect(),Y=X.height,D=X.width,O=X.top,j=X.right,B=X.bottom,C=X.left;if("if-needed"===l&&M>=0&&x>=0&&H<=v&&T<=p&&M>=O&&H<=B&&x>=C&&T<=j)return V;var P=getComputedStyle(L),R=parseInt(P.borderLeftWidth,10),S=parseInt(P.borderTopWidth,10),q=parseInt(P.borderRightWidth,10),A=parseInt(P.borderBottomWidth,10),F=0,z=0,G="offsetWidth"in L?L.offsetWidth-L.clientWidth-R-q:0,J="offsetHeight"in L?L.offsetHeight-L.clientHeight-S-A:0;if(d===L)F="start"===c?E:"end"===c?E-v:"nearest"===c?r(w,w+v,v,S,A,w+E,w+E+y,y):E-v/2,z="start"===u?k:"center"===u?k-p/2:"end"===u?k-p:r(b,b+p,p,R,q,b+k,b+k+W,W),F=Math.max(0,F+w),z=Math.max(0,z+b);else{F="start"===c?E-O-S:"end"===c?E-B+A+J:"nearest"===c?r(O,B,Y,S,A+J,E,E+y,y):E-(O+Y/2)+J/2,z="start"===u?k-C-R:"center"===u?k-(C+D/2)+G/2:"end"===u?k-j+q+G:r(C,j,D,R,q+G,k,k+W,W);var K=L.scrollLeft,N=L.scrollTop;E+=N-(F=Math.max(0,Math.min(N+F,L.scrollHeight-Y+J))),k+=K-(z=Math.max(0,Math.min(K+z,L.scrollWidth-D+G)))}V.push({el:L,top:F,left:z})}return V}function i(e){return e===Object(e)&&0!==Object.keys(e).length}function l(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(i(t)&&"function"==typeof t.behavior)return t.behavior(n?[]:o(e,t));if(!n){var r=function(e){return!1===e?{block:"end",inline:"nearest"}:i(e)?e:{block:"start",inline:"nearest"}}(t);return function(e,t){void 0===t&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach((function(e){var r=e.el,o=e.top,i=e.left;r.scroll&&n?r.scroll({top:o,left:i,behavior:t}):(r.scrollTop=o,r.scrollLeft=i)}))}(o(e,r),r.behavior)}}var c,u=function(){return c||(c="performance"in window?performance.now.bind(performance):Date.now),c()};function a(e){var t=u(),n=Math.min((t-e.startTime)/e.duration,1),r=e.ease(n),o=e.startX+(e.x-e.startX)*r,i=e.startY+(e.y-e.startY)*r;e.method(o,i),o!==e.x||i!==e.y?requestAnimationFrame((function(){return a(e)})):e.cb()}function f(e,t,n,r,o,i){var l,c,f;void 0===r&&(r=600),void 0===o&&(o=function(e){return 1+--e*e*e*e*e}),l=e,c=e.scrollLeft,f=e.scrollTop,a({scrollable:l,method:function(t,n){e.scrollLeft=Math.ceil(t),e.scrollTop=Math.ceil(n)},startTime:u(),startX:c,startY:f,x:t,y:n,duration:r,ease:o,cb:i})}return function(e,t){var n=t||{};return function(e){return e&&!e.behavior||"smooth"===e.behavior}(n)?l(e,{block:n.block,inline:n.inline,scrollMode:n.scrollMode,boundary:n.boundary,behavior:function(e){return Promise.all(e.reduce((function(e,t){var r=t.el,o=t.left,i=t.top,l=r.scrollLeft,c=r.scrollTop;return l===o&&c===i?e:[].concat(e,[new Promise((function(e){return f(r,o,i,n.duration,n.ease,(function(){return e({el:r,left:[l,o],top:[c,i]})}))}))])}),[]))}}):Promise.resolve(l(e,t))}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).scrollIntoView=t()}(this,(function(){"use strict";function e(e){return"object"==typeof e&&null!=e&&1===e.nodeType}function t(e,t){return(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e}function n(e,n){if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){var r=getComputedStyle(e,null);return t(r.overflowY,n)||t(r.overflowX,n)||function(e){var t=function(e){if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}}(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)}(e)}return!1}function r(e,t,n,r,o,i,l,c){return i<e&&l>t||i>e&&l<t?0:i<=e&&c<=n||l>=t&&c>=n?i-e-r:l>t&&c<n||i<e&&c>n?l-t+o:0}function o(t,o){var i=window,l=o.scrollMode,c=o.block,u=o.inline,a=o.boundary,f=o.skipOverflowHiddenElements,s="function"==typeof a?a:function(e){return e!==a};if(!e(t))throw new TypeError("Invalid target");for(var d=document.scrollingElement||document.documentElement,h=[],m=t;e(m)&&s(m);){if((m=m.parentElement)===d){h.push(m);break}null!=m&&m===document.body&&n(m)&&!n(document.documentElement)||null!=m&&n(m,f)&&h.push(m)}for(var p=i.visualViewport?i.visualViewport.width:innerWidth,v=i.visualViewport?i.visualViewport.height:innerHeight,b=window.scrollX||pageXOffset,w=window.scrollY||pageYOffset,g=t.getBoundingClientRect(),y=g.height,W=g.width,M=g.top,T=g.right,H=g.bottom,x=g.left,E="start"===c||"nearest"===c?M:"end"===c?H:M+y/2,k="center"===u?x+W/2:"end"===u?T:x,V=[],I=0;I<h.length;I++){var L=h[I],X=L.getBoundingClientRect(),Y=X.height,C=X.width,D=X.top,O=X.right,j=X.bottom,B=X.left;if("if-needed"===l&&M>=0&&x>=0&&H<=v&&T<=p&&M>=D&&H<=j&&x>=B&&T<=O)return V;var P=getComputedStyle(L),R=parseInt(P.borderLeftWidth,10),S=parseInt(P.borderTopWidth,10),q=parseInt(P.borderRightWidth,10),A=parseInt(P.borderBottomWidth,10),F=0,z=0,G="offsetWidth"in L?L.offsetWidth-L.clientWidth-R-q:0,J="offsetHeight"in L?L.offsetHeight-L.clientHeight-S-A:0;if(d===L)F="start"===c?E:"end"===c?E-v:"nearest"===c?r(w,w+v,v,S,A,w+E,w+E+y,y):E-v/2,z="start"===u?k:"center"===u?k-p/2:"end"===u?k-p:r(b,b+p,p,R,q,b+k,b+k+W,W),F=Math.max(0,F+w),z=Math.max(0,z+b);else{F="start"===c?E-D-S:"end"===c?E-j+A+J:"nearest"===c?r(D,j,Y,S,A+J,E,E+y,y):E-(D+Y/2)+J/2,z="start"===u?k-B-R:"center"===u?k-(B+C/2)+G/2:"end"===u?k-O+q+G:r(B,O,C,R,q+G,k,k+W,W);var K=L.scrollLeft,N=L.scrollTop;E+=N-(F=Math.max(0,Math.min(N+F,L.scrollHeight-Y+J))),k+=K-(z=Math.max(0,Math.min(K+z,L.scrollWidth-C+G)))}V.push({el:L,top:F,left:z})}return V}function i(e){return e===Object(e)&&0!==Object.keys(e).length}function l(e,t){var n=e.isConnected||e.ownerDocument.documentElement.contains(e);if(i(t)&&"function"==typeof t.behavior)return t.behavior(n?o(e,t):[]);if(n){var r=function(e){return!1===e?{block:"end",inline:"nearest"}:i(e)?e:{block:"start",inline:"nearest"}}(t);return function(e,t){void 0===t&&(t="auto");var n="scrollBehavior"in document.body.style;e.forEach((function(e){var r=e.el,o=e.top,i=e.left;r.scroll&&n?r.scroll({top:o,left:i,behavior:t}):(r.scrollTop=o,r.scrollLeft=i)}))}(o(e,r),r.behavior)}}var c,u=function(){return c||(c="performance"in window?performance.now.bind(performance):Date.now),c()};function a(e){var t=u(),n=Math.min((t-e.startTime)/e.duration,1),r=e.ease(n),o=e.startX+(e.x-e.startX)*r,i=e.startY+(e.y-e.startY)*r;e.method(o,i),o!==e.x||i!==e.y?requestAnimationFrame((function(){return a(e)})):e.cb()}function f(e,t,n,r,o,i){var l,c,f,s;void 0===r&&(r=600),void 0===o&&(o=function(e){return 1+--e*e*e*e*e}),l=e,c=e.scrollLeft,f=e.scrollTop,s=function(t,n){e.scrollLeft=Math.ceil(t),e.scrollTop=Math.ceil(n)},a({scrollable:l,method:s,startTime:u(),startX:c,startY:f,x:t,y:n,duration:r,ease:o,cb:i})}return function(e,t){var n=t||{};return function(e){return e&&!e.behavior||"smooth"===e.behavior}(n)?l(e,{block:n.block,inline:n.inline,scrollMode:n.scrollMode,boundary:n.boundary,behavior:function(e){return Promise.all(e.reduce((function(e,t){var r=t.el,o=t.left,i=t.top,l=r.scrollLeft,c=r.scrollTop;return l===o&&c===i?e:[].concat(e,[new Promise((function(e){return f(r,o,i,n.duration,n.ease,(function(){return e({el:r,left:[l,o],top:[c,i]})}))}))])}),[]))}}):Promise.resolve(l(e,t))}})); |
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
28549