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.14 to 2.2.15

10

package.json

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

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

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

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

@@ -59,3 +59,3 @@ "devDependencies": {

"rimraf": "2.6.2",
"rollup": "0.63.2",
"rollup": "0.63.4",
"rollup-plugin-babel": "4.0.0-beta.7",

@@ -66,5 +66,5 @@ "rollup-plugin-commonjs": "9.1.3",

"rollup-plugin-terser": "1.0.1",
"semantic-release": "15.8.0",
"semantic-release": "15.8.1",
"tslint": "5.11.0",
"tslint-config-prettier": "1.13.0",
"tslint-config-prettier": "1.14.0",
"typescript": "2.9.2"

@@ -71,0 +71,0 @@ },

@@ -70,2 +70,6 @@ (function (global, factory) {

if (cursor === document.body && isScrollable(cursor) && !isScrollable(document.documentElement)) {
continue;
}
if (isScrollable(cursor, skipOverflowHiddenElements)) {

@@ -99,8 +103,8 @@ frames.push(cursor);

_width = _frame$getBoundingCli.width,
top = _frame$getBoundingCli.top,
_top = _frame$getBoundingCli.top,
right = _frame$getBoundingCli.right,
bottom = _frame$getBoundingCli.bottom,
left = _frame$getBoundingCli.left;
_left = _frame$getBoundingCli.left;
if (scrollMode === 'if-needed' && targetTop >= 0 && targetLeft >= 0 && targetBottom <= viewportHeight && targetRight <= viewportWidth && targetTop >= top && targetBottom <= bottom && targetLeft >= left && targetRight <= right) {
if (scrollMode === 'if-needed' && targetTop >= 0 && targetLeft >= 0 && targetBottom <= viewportHeight && targetRight <= viewportWidth && targetTop >= _top && targetBottom <= bottom && targetLeft >= _left && targetRight <= right) {
return computations;

@@ -144,19 +148,19 @@ }

if (block === 'start') {
blockScroll = targetBlock - top - borderTop;
blockScroll = targetBlock - _top - borderTop;
} else if (block === 'end') {
blockScroll = targetBlock - bottom + borderBottom + scrollbarHeight;
} else if (block === 'nearest') {
blockScroll = alignNearest(top, bottom, _height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight);
blockScroll = alignNearest(_top, bottom, _height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight);
} else {
blockScroll = targetBlock - (top + _height / 2) + scrollbarHeight / 2;
blockScroll = targetBlock - (_top + _height / 2) + scrollbarHeight / 2;
}
if (inline === 'start') {
inlineScroll = targetInline - left - borderLeft;
inlineScroll = targetInline - _left - borderLeft;
} else if (inline === 'center') {
inlineScroll = targetInline - (left + _width / 2) + scrollbarWidth / 2;
inlineScroll = targetInline - (_left + _width / 2) + scrollbarWidth / 2;
} else if (inline === 'end') {
inlineScroll = targetInline - right + borderRight + scrollbarWidth;
} else {
inlineScroll = alignNearest(left, right, _width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth);
inlineScroll = alignNearest(_left, right, _width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth);
}

@@ -163,0 +167,0 @@

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

!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)}});
!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,c=r.skipOverflowHiddenElements,s="function"==typeof f?f:function(e){return e!==f};if(!e(t))throw new TypeError("Invalid target");for(var a=document.scrollingElement||document.documentElement,u=[],h=t;e(h)&&s(h);){if((h=h.parentNode||h.host)===a){u.push(h);break}h===document.body&&n(h)&&!n(document.documentElement)||n(h,c)&&u.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,v=window.visualViewport?visualViewport.height:innerHeight,g=window.scrollX||pageXOffset,m=window.scrollY||pageYOffset,b=t.getBoundingClientRect(),w=b.height,y=b.width,W=b.top,H=b.right,M=b.bottom,k=b.left,x="start"===l||"nearest"===l?W:"end"===l?M:W+w/2,E="center"===d?k+y/2:"end"===d?H:k,I=[],T=0;T<u.length;T++){var O=u[T],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 I;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(a===O)A="start"===l?x:"end"===l?x-v:"nearest"===l?o(m,m+v,v,N,z,m+x,m+x+w,w):x-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=Math.max(0,A+m),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?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=O.scrollLeft,K=O.scrollTop;x+=K-(A=Math.max(0,Math.min(K+A,O.scrollHeight-j+G))),E+=J-(D=Math.max(0,Math.min(J+D,O.scrollWidth-B+F)))}I.push({el:O,top:A,left:D})}return I};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)}});
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