Socket
Socket
Sign inDemoInstall

scroll-into-view-if-needed

Package Overview
Dependencies
1
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.13 to 2.2.14

4

package.json

@@ -11,3 +11,3 @@ {

},
"version": "2.2.13",
"version": "2.2.14",
"main": "index.js",

@@ -36,3 +36,3 @@ "module": "es/index.js",

"dependencies": {
"compute-scroll-into-view": "1.0.4"
"compute-scroll-into-view": "1.0.5"
},

@@ -39,0 +39,0 @@ "devDependencies": {

@@ -138,4 +138,4 @@ (function (global, factory) {

blockScroll += viewportY;
inlineScroll += viewportX;
blockScroll = Math.max(0, blockScroll + viewportY);
inlineScroll = Math.max(0, inlineScroll + viewportX);
} else {

@@ -142,0 +142,0 @@ if (block === 'start') {

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.scrollIntoView=t()}(this,function(){"use strict";function e(e){return null!=e&&"object"==typeof e&&(1===e.nodeType||11===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 o=getComputedStyle(e,null);return t(o.overflowY,n)||t(o.overflowX,n)}return!1}function o(e,t,n,o,r,i,l,d){return i<e&&l>t||i>e&&l<t?0:i<e&&d<n||l>t&&d>n?i-e-o:l>t&&d<n||i<e&&d>n?l-t+r:0}var r=function(t,r){var i=r.scrollMode,l=r.block,d=r.inline,f=r.boundary,s=r.skipOverflowHiddenElements,c="function"==typeof f?f:function(e){return e!==f};if(!e(t))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,a=[],h=t;e(h)&&c(h);){if((h=h.parentNode||h.host)===u){a.push(h);break}n(h,s)&&a.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,v=window.visualViewport?visualViewport.height:innerHeight,g=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,w=t.getBoundingClientRect(),m=w.height,y=w.width,W=w.top,H=w.right,k=w.bottom,I=w.left,T="start"===l||"nearest"===l?W:"end"===l?k:W+m/2,E="center"===d?I+y/2:"end"===d?H:I,M=[],O=0;O<a.length;O++){var V=a[O],j=V.getBoundingClientRect(),x=j.height,B=j.width,C=j.top,L=j.right,R=j.bottom,X=j.left;if("if-needed"===i&&W>=0&&I>=0&&k<=v&&H<=p&&W>=C&&k<=R&&I>=X&&H<=L)return M;var Y=getComputedStyle(V),S=parseInt(Y.borderLeftWidth,10),N=parseInt(Y.borderTopWidth,10),q=parseInt(Y.borderRightWidth,10),z=parseInt(Y.borderBottomWidth,10),A=0,D=0,F="offsetWidth"in V?V.offsetWidth-V.clientWidth-S-q:0,G="offsetHeight"in V?V.offsetHeight-V.clientHeight-N-z:0;if(u===V)A="start"===l?T:"end"===l?T-v:"nearest"===l?o(b,b+v,v,N,z,b+T,b+T+m,m):T-v/2,D="start"===d?E:"center"===d?E-p/2:"end"===d?E-p:o(g,g+p,p,S,q,g+E,g+E+y,y),A+=b,D+=g;else{A="start"===l?T-C-N:"end"===l?T-R+z+G:"nearest"===l?o(C,R,x,N,z+G,T,T+m,m):T-(C+x/2)+G/2,D="start"===d?E-X-S:"center"===d?E-(X+B/2)+F/2:"end"===d?E-L+q+F:o(X,L,B,S,q+F,E,E+y,y);var J=V.scrollLeft,K=V.scrollTop;T+=K-(A=Math.max(0,Math.min(K+A,V.scrollHeight-x+G))),E+=J-(D=Math.max(0,Math.min(J+D,V.scrollWidth-B+F)))}M.push({el:V,top:A,left:D})}return M};function i(e){return e===Object(e)&&0!==Object.keys(e).length}return function(e,t){if(i(t)&&"function"==typeof t.behavior)return t.behavior(r(e,t));var n=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 o=e.el,r=e.top,i=e.left;o.scroll&&n?o.scroll({top:r,left:i,behavior:t}):(o.scrollTop=r,o.scrollLeft=i)})}(r(e,n),n.behavior)}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.scrollIntoView=e()}(this,function(){"use strict";function t(t){return null!=t&&"object"==typeof t&&(1===t.nodeType||11===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 o=getComputedStyle(t,null);return e(o.overflowY,n)||e(o.overflowX,n)}return!1}function o(t,e,n,o,r,i,l,d){return i<t&&l>e||i>t&&l<e?0:i<t&&d<n||l>e&&d>n?i-t-o:l>e&&d<n||i<t&&d>n?l-e+r:0}var r=function(e,r){var i=r.scrollMode,l=r.block,d=r.inline,f=r.boundary,s=r.skipOverflowHiddenElements,a="function"==typeof f?f:function(t){return t!==f};if(!t(e))throw new TypeError("Invalid target");for(var c=document.scrollingElement||document.documentElement,u=[],h=e;t(h)&&a(h);){if((h=h.parentNode||h.host)===c){u.push(h);break}n(h,s)&&u.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,v=window.visualViewport?visualViewport.height:innerHeight,g=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,m=e.getBoundingClientRect(),w=m.height,y=m.width,W=m.top,H=m.right,M=m.bottom,k=m.left,x="start"===l||"nearest"===l?W:"end"===l?M:W+w/2,I="center"===d?k+y/2:"end"===d?H:k,T=[],E=0;E<u.length;E++){var O=u[E],V=O.getBoundingClientRect(),j=V.height,B=V.width,C=V.top,L=V.right,R=V.bottom,X=V.left;if("if-needed"===i&&W>=0&&k>=0&&M<=v&&H<=p&&W>=C&&M<=R&&k>=X&&H<=L)return T;var Y=getComputedStyle(O),S=parseInt(Y.borderLeftWidth,10),N=parseInt(Y.borderTopWidth,10),q=parseInt(Y.borderRightWidth,10),z=parseInt(Y.borderBottomWidth,10),A=0,D=0,F="offsetWidth"in O?O.offsetWidth-O.clientWidth-S-q:0,G="offsetHeight"in O?O.offsetHeight-O.clientHeight-N-z:0;if(c===O)A="start"===l?x:"end"===l?x-v:"nearest"===l?o(b,b+v,v,N,z,b+x,b+x+w,w):x-v/2,D="start"===d?I:"center"===d?I-p/2:"end"===d?I-p:o(g,g+p,p,S,q,g+I,g+I+y,y),A=Math.max(0,A+b),D=Math.max(0,D+g);else{A="start"===l?x-C-N:"end"===l?x-R+z+G:"nearest"===l?o(C,R,j,N,z+G,x,x+w,w):x-(C+j/2)+G/2,D="start"===d?I-X-S:"center"===d?I-(X+B/2)+F/2:"end"===d?I-L+q+F:o(X,L,B,S,q+F,I,I+y,y);var J=O.scrollLeft,K=O.scrollTop;x+=K-(A=Math.max(0,Math.min(K+A,O.scrollHeight-j+G))),I+=J-(D=Math.max(0,Math.min(J+D,O.scrollWidth-B+F)))}T.push({el:O,top:A,left:D})}return T};function i(t){return t===Object(t)&&0!==Object.keys(t).length}return function(t,e){if(i(e)&&"function"==typeof e.behavior)return e.behavior(r(t,e));var n=function(t){return!1===t?{block:"end",inline:"nearest"}:i(t)?t:{block:"start",inline:"nearest"}}(e);return function(t,e){void 0===e&&(e="auto");var n="scrollBehavior"in document.body.style;t.forEach(function(t){var o=t.el,r=t.top,i=t.left;o.scroll&&n?o.scroll({top:r,left:i,behavior:e}):(o.scrollTop=r,o.scrollLeft=i)})}(r(t,n),n.behavior)}});
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc