Socket
Socket
Sign inDemoInstall

scroll-into-view-if-needed

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-into-view-if-needed - npm Package Compare versions

Comparing version 2.2.6 to 2.2.7

10

compute.js

@@ -128,2 +128,4 @@ "use strict";

var borderBottom = parseInt(frameStyle.borderBottomWidth, 10);
var scrollbarWidth = 'offsetWidth' in frame ? frame.offsetWidth - frame.clientWidth - borderLeft - borderRight : 0;
var scrollbarHeight = 'offsetHeight' in frame ? frame.offsetHeight - frame.clientHeight - borderTop - borderBottom : 0;
var blockScroll = 0;

@@ -169,3 +171,3 @@ var inlineScroll = 0;

blockScroll = frame.scrollTop + _offset2 + borderBottom;
blockScroll = frame.scrollTop + _offset2 + borderBottom + scrollbarHeight;
}

@@ -184,3 +186,3 @@ }

} else {
var _offset4 = alignNearest(frameRect.top, frameRect.bottom, frameRect.height, borderTop, borderBottom, targetBlock, targetBlock + targetRect.height, targetRect.height);
var _offset4 = alignNearest(frameRect.top, frameRect.bottom, frameRect.height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetRect.height, targetRect.height);

@@ -229,3 +231,3 @@ blockScroll = frame.scrollTop + _offset4;

inlineScroll = frame.scrollLeft + _offset7 + borderRight;
inlineScroll = frame.scrollLeft + _offset7 + borderRight + scrollbarWidth;
}

@@ -244,3 +246,3 @@ }

} else {
var _offset9 = alignNearest(frameRect.left, frameRect.right, frameRect.width, borderLeft, borderRight, targetInline, targetInline + targetRect.width, targetRect.width);
var _offset9 = alignNearest(frameRect.left, frameRect.right, frameRect.width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetRect.width, targetRect.width);

@@ -247,0 +249,0 @@ inlineScroll = frame.scrollLeft + _offset9;

@@ -121,2 +121,4 @@ import getViewport from './viewport';

var borderBottom = parseInt(frameStyle.borderBottomWidth, 10);
var scrollbarWidth = 'offsetWidth' in frame ? frame.offsetWidth - frame.clientWidth - borderLeft - borderRight : 0;
var scrollbarHeight = 'offsetHeight' in frame ? frame.offsetHeight - frame.clientHeight - borderTop - borderBottom : 0;
var blockScroll = 0;

@@ -162,3 +164,3 @@ var inlineScroll = 0;

blockScroll = frame.scrollTop + _offset2 + borderBottom;
blockScroll = frame.scrollTop + _offset2 + borderBottom + scrollbarHeight;
}

@@ -177,3 +179,3 @@ }

} else {
var _offset4 = alignNearest(frameRect.top, frameRect.bottom, frameRect.height, borderTop, borderBottom, targetBlock, targetBlock + targetRect.height, targetRect.height);
var _offset4 = alignNearest(frameRect.top, frameRect.bottom, frameRect.height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetRect.height, targetRect.height);

@@ -222,3 +224,3 @@ blockScroll = frame.scrollTop + _offset4;

inlineScroll = frame.scrollLeft + _offset7 + borderRight;
inlineScroll = frame.scrollLeft + _offset7 + borderRight + scrollbarWidth;
}

@@ -237,3 +239,3 @@ }

} else {
var _offset9 = alignNearest(frameRect.left, frameRect.right, frameRect.width, borderLeft, borderRight, targetInline, targetInline + targetRect.width, targetRect.width);
var _offset9 = alignNearest(frameRect.left, frameRect.right, frameRect.width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetRect.width, targetRect.width);

@@ -240,0 +242,0 @@ inlineScroll = frame.scrollLeft + _offset9;

22

package.json

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

},
"version": "2.2.6",
"version": "2.2.7",
"main": "index.js",

@@ -38,14 +38,14 @@ "module": "es/index.js",

"devDependencies": {
"@babel/cli": "7.0.0-beta.50",
"@babel/core": "7.0.0-beta.49",
"@babel/cli": "7.0.0-beta.51",
"@babel/core": "7.0.0-beta.51",
"@babel/plugin-external-helpers": "7.0.0-beta.51",
"@babel/preset-env": "7.0.0-beta.50",
"@babel/preset-typescript": "7.0.0-beta.50",
"babel-eslint": "8.2.3",
"@babel/preset-env": "7.0.0-beta.51",
"@babel/preset-typescript": "7.0.0-beta.51",
"babel-eslint": "8.2.5",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-dev-expression": "0.2.1",
"concurrently": "3.5.1",
"concurrently": "3.6.0",
"eslint": "4.19.1",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-import": "2.12.0",
"eslint-plugin-import": "2.13.0",
"eslint-plugin-react": "7.9.1",

@@ -58,3 +58,3 @@ "flowgen": "1.2.2",

"rimraf": "2.6.2",
"rollup": "0.60.2",
"rollup": "0.61.2",
"rollup-plugin-babel": "4.0.0-beta.5",

@@ -65,6 +65,6 @@ "rollup-plugin-commonjs": "9.1.3",

"rollup-plugin-terser": "1.0.1",
"semantic-release": "15.5.2",
"semantic-release": "15.6.0",
"tslint": "5.10.0",
"tslint-config-prettier": "1.13.0",
"typescript": "2.9.1"
"typescript": "2.9.2"
},

@@ -71,0 +71,0 @@ "keywords": [

@@ -134,2 +134,4 @@ (function (global, factory) {

var borderBottom = parseInt(frameStyle.borderBottomWidth, 10);
var scrollbarWidth = 'offsetWidth' in frame ? frame.offsetWidth - frame.clientWidth - borderLeft - borderRight : 0;
var scrollbarHeight = 'offsetHeight' in frame ? frame.offsetHeight - frame.clientHeight - borderTop - borderBottom : 0;
var blockScroll = 0;

@@ -175,3 +177,3 @@ var inlineScroll = 0;

blockScroll = frame.scrollTop + _offset2 + borderBottom;
blockScroll = frame.scrollTop + _offset2 + borderBottom + scrollbarHeight;
}

@@ -190,3 +192,3 @@ }

} else {
var _offset4 = alignNearest(frameRect.top, frameRect.bottom, frameRect.height, borderTop, borderBottom, targetBlock, targetBlock + targetRect.height, targetRect.height);
var _offset4 = alignNearest(frameRect.top, frameRect.bottom, frameRect.height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetRect.height, targetRect.height);

@@ -235,3 +237,3 @@ blockScroll = frame.scrollTop + _offset4;

inlineScroll = frame.scrollLeft + _offset7 + borderRight;
inlineScroll = frame.scrollLeft + _offset7 + borderRight + scrollbarWidth;
}

@@ -250,3 +252,3 @@ }

} else {
var _offset9 = alignNearest(frameRect.left, frameRect.right, frameRect.width, borderLeft, borderRight, targetInline, targetInline + targetRect.width, targetRect.width);
var _offset9 = alignNearest(frameRect.left, frameRect.right, frameRect.width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetRect.width, targetRect.width);

@@ -253,0 +255,0 @@ inlineScroll = frame.scrollLeft + _offset9;

@@ -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";var t,e=function(){return t||(t="CSS1Compat"===document.compatMode?document.documentElement:document.scrollingElement||document.documentElement),t},o=function(t){return null!=t&&"object"==typeof t&&(1===t.nodeType||11===t.nodeType)},i=function(t,e){return"X"===e?t.clientWidth<t.scrollWidth:t.clientHeight<t.scrollHeight},n=function(t,e,o){var i=getComputedStyle(t,null)["overflow"+e];return(!o||"hidden"!==i)&&("visible"!==i&&"clip"!==i)},r=function(t,o){return t===e()||i(t,"Y")&&n(t,"Y",o)||i(t,"X")&&n(t,"X",o)},l=function(t,e,o,i,n,r,l,f){return r<t&&l>e||r>t&&l<e?0:r<t&&f<o||l>e&&f>o?r-t-i:l>e&&f<o||r<t&&f>o?l-e+n:0},f=function(t,i){void 0===i&&(i={});var n=i,f=n.scrollMode,c=void 0===f?"always":f,d=n.block,s=void 0===d?"center":d,u=n.inline,h=void 0===u?"nearest":u,a=n.boundary,p=n.skipOverflowHiddenElements,v=void 0!==p&&p,w="function"==typeof a?a:function(t){return t!==a};if(!o(t))throw new Error("Element is required in scrollIntoView");for(var m,g=t.getBoundingClientRect(),b=[];o(m=t.parentNode||t.host)&&w(t);)r(m,v)&&b.push(m),t=m;var y,T,L=e(),M=window.visualViewport?window.visualViewport.width:Math.min(L.clientWidth,window.innerWidth),H=window.visualViewport?window.visualViewport.height:Math.min(L.clientHeight,window.innerHeight),W=window.scrollX||window.pageXOffset,C=window.scrollY||window.pageYOffset;if("if-needed"===c&&b.every(function(t){var e=t.getBoundingClientRect();if(g.top<e.top)return!1;if(g.bottom>e.bottom)return!1;if(t===L){if(g.bottom>H||g.top<0)return!1;if(g.left>M||g.right<0)return!1}return!0}))return[];return b.map(function(t){var e=t.getBoundingClientRect(),o=getComputedStyle(t),i=parseInt(o.borderLeftWidth,10),n=parseInt(o.borderTopWidth,10),r=parseInt(o.borderRightWidth,10),f=parseInt(o.borderBottomWidth,10),c=0,d=0;if("start"===s)if(y||(y=g.top),L===t)c=C+y;else{var u=Math.min(y-e.top,t.scrollHeight-t.clientHeight-t.scrollTop);c=t.scrollTop+u-n}if("center"===s)if(y||(y=g.top+g.height/2),L===t)c=C+y-H/2;else{var a=0-Math.min(e.top+e.height/2-y,t.scrollTop);c=t.scrollTop+a}if("end"===s)if(y||(y=g.bottom),L===t)c=C+y-H;else{var p=0-Math.min(e.bottom-y,t.scrollTop);c=t.scrollTop+p+f}if("nearest"===s)if(y||(y=g.top),L===t){var v=l(C,C+H,H,n,f,C+y,C+y+g.height,g.height);c=C+v}else{var w=l(e.top,e.bottom,e.height,n,f,y,y+g.height,g.height);c=t.scrollTop+w}if("start"===h)if(T||(T=g.left),L===t)d=W+T;else{var m=Math.min(T-e.left,t.scrollHeight-t.clientLeft-t.scrollLeft);d=t.scrollLeft+m-i}if("center"===h)if(T||(T=g.left+g.width/2),L===t)d=W+T-M/2;else{var b=0-Math.min(e.left+e.width/2-T,t.scrollLeft);d=t.scrollLeft+b}if("end"===h)if(T||(T=g.right),L===t)d=W+T-M;else{var E=0-Math.min(e.right-T,t.scrollLeft);d=t.scrollLeft+E+r}if("nearest"===h)if(T||(T=g.left),L===t){var k=l(W,W+M,M,i,r,W+T,W+T+g.width,g.width);d=W+k}else{var I=l(e.left,e.right,e.width,i,r,T,T+g.width,g.width);d=t.scrollLeft+I}return y+=t.scrollTop-c,T+=t.scrollLeft-d,{el:t,top:c,left:d}})},c=function(t){return"function"==typeof t},d=function(t){return t===Object(t)&&0!==Object.keys(t).length},s=function(t,o){void 0===o&&(o="auto");var i=e(),n="scrollBehavior"in i.style;t.forEach(function(t){var e=t.el,r=t.top,l=t.left;e.scroll&&n?e.scroll({top:r,left:l,behavior:o}):e===i?window.scrollTo(l,r):(e.scrollTop=r,e.scrollLeft=l)})},u=function(t){return void 0===t&&(t=!0),!0===t||null===t?{block:"start",inline:"nearest"}:!1===t?{block:"end",inline:"nearest"}:d(t)?t:{block:"start",inline:"nearest"}};return function(t,e){if(void 0===e&&(e=!0),d(e)&&c(e.behavior))return e.behavior(f(t,e));var o=u(e);return s(f(t,o),o.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";var t,e=function(){return t||(t="CSS1Compat"===document.compatMode?document.documentElement:document.scrollingElement||document.documentElement),t},i=function(t){return null!=t&&"object"==typeof t&&(1===t.nodeType||11===t.nodeType)},o=function(t,e){return"X"===e?t.clientWidth<t.scrollWidth:t.clientHeight<t.scrollHeight},n=function(t,e,i){var o=getComputedStyle(t,null)["overflow"+e];return(!i||"hidden"!==o)&&("visible"!==o&&"clip"!==o)},r=function(t,i){return t===e()||o(t,"Y")&&n(t,"Y",i)||o(t,"X")&&n(t,"X",i)},l=function(t,e,i,o,n,r,l,f){return r<t&&l>e||r>t&&l<e?0:r<t&&f<i||l>e&&f>i?r-t-o:l>e&&f<i||r<t&&f>i?l-e+n:0},f=function(t,o){void 0===o&&(o={});var n=o,f=n.scrollMode,c=void 0===f?"always":f,s=n.block,d=void 0===s?"center":s,h=n.inline,u=void 0===h?"nearest":h,a=n.boundary,p=n.skipOverflowHiddenElements,v=void 0!==p&&p,w="function"==typeof a?a:function(t){return t!==a};if(!i(t))throw new Error("Element is required in scrollIntoView");for(var g,m=t.getBoundingClientRect(),b=[];i(g=t.parentNode||t.host)&&w(t);)r(g,v)&&b.push(g),t=g;var y,T,H=e(),L=window.visualViewport?window.visualViewport.width:Math.min(H.clientWidth,window.innerWidth),W=window.visualViewport?window.visualViewport.height:Math.min(H.clientHeight,window.innerHeight),M=window.scrollX||window.pageXOffset,C=window.scrollY||window.pageYOffset;if("if-needed"===c&&b.every(function(t){var e=t.getBoundingClientRect();if(m.top<e.top)return!1;if(m.bottom>e.bottom)return!1;if(t===H){if(m.bottom>W||m.top<0)return!1;if(m.left>L||m.right<0)return!1}return!0}))return[];return b.map(function(t){var e=t.getBoundingClientRect(),i=getComputedStyle(t),o=parseInt(i.borderLeftWidth,10),n=parseInt(i.borderTopWidth,10),r=parseInt(i.borderRightWidth,10),f=parseInt(i.borderBottomWidth,10),c="offsetWidth"in t?t.offsetWidth-t.clientWidth-o-r:0,s="offsetHeight"in t?t.offsetHeight-t.clientHeight-n-f:0,h=0,a=0;if("start"===d)if(y||(y=m.top),H===t)h=C+y;else{var p=Math.min(y-e.top,t.scrollHeight-t.clientHeight-t.scrollTop);h=t.scrollTop+p-n}if("center"===d)if(y||(y=m.top+m.height/2),H===t)h=C+y-W/2;else{var v=0-Math.min(e.top+e.height/2-y,t.scrollTop);h=t.scrollTop+v}if("end"===d)if(y||(y=m.bottom),H===t)h=C+y-W;else{var w=0-Math.min(e.bottom-y,t.scrollTop);h=t.scrollTop+w+f+s}if("nearest"===d)if(y||(y=m.top),H===t){var g=l(C,C+W,W,n,f,C+y,C+y+m.height,m.height);h=C+g}else{var b=l(e.top,e.bottom,e.height,n,f+s,y,y+m.height,m.height);h=t.scrollTop+b}if("start"===u)if(T||(T=m.left),H===t)a=M+T;else{var E=Math.min(T-e.left,t.scrollHeight-t.clientLeft-t.scrollLeft);a=t.scrollLeft+E-o}if("center"===u)if(T||(T=m.left+m.width/2),H===t)a=M+T-L/2;else{var k=0-Math.min(e.left+e.width/2-T,t.scrollLeft);a=t.scrollLeft+k}if("end"===u)if(T||(T=m.right),H===t)a=M+T-L;else{var I=0-Math.min(e.right-T,t.scrollLeft);a=t.scrollLeft+I+r+c}if("nearest"===u)if(T||(T=m.left),H===t){var V=l(M,M+L,L,o,r,M+T,M+T+m.width,m.width);a=M+V}else{var B=l(e.left,e.right,e.width,o,r+c,T,T+m.width,m.width);a=t.scrollLeft+B}return y+=t.scrollTop-h,T+=t.scrollLeft-a,{el:t,top:h,left:a}})},c=function(t){return"function"==typeof t},s=function(t){return t===Object(t)&&0!==Object.keys(t).length},d=function(t,i){void 0===i&&(i="auto");var o=e(),n="scrollBehavior"in o.style;t.forEach(function(t){var e=t.el,r=t.top,l=t.left;e.scroll&&n?e.scroll({top:r,left:l,behavior:i}):e===o?window.scrollTo(l,r):(e.scrollTop=r,e.scrollLeft=l)})},h=function(t){return void 0===t&&(t=!0),!0===t||null===t?{block:"start",inline:"nearest"}:!1===t?{block:"end",inline:"nearest"}:s(t)?t:{block:"start",inline:"nearest"}};return function(t,e){if(void 0===e&&(e=!0),s(e)&&c(e.behavior))return e.behavior(f(t,e));var i=h(e);return d(f(t,i),i.behavior)}});
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