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.18 to 2.2.19

8

package.json

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

},
"version": "2.2.18",
"version": "2.2.19",
"main": "index.js",

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

"dependencies": {
"compute-scroll-into-view": "1.0.10"
"compute-scroll-into-view": "1.0.11"
},

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

"rollup-plugin-node-resolve": "3.4.0",
"rollup-plugin-replace": "2.0.0",
"rollup-plugin-replace": "2.1.0",
"rollup-plugin-terser": "3.0.0",

@@ -69,3 +69,3 @@ "semantic-release": "15.9.17",

"tslint-config-prettier": "1.15.0",
"typescript": "3.0.3"
"typescript": "3.1.1"
},

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

@@ -13,3 +13,3 @@ export declare type ScrollBehavior = 'auto' | 'instant' | 'smooth';

export declare type CustomScrollBoundaryCallback = (parent: Element) => boolean;
export declare type CustomScrollBoundary = Element | CustomScrollBoundaryCallback;
export declare type CustomScrollBoundary = Element | CustomScrollBoundaryCallback | null;
export interface CustomScrollAction {

@@ -16,0 +16,0 @@ el: Element;

@@ -33,3 +33,3 @@ (function (global, factory) {

if (elementEdgeStart < scrollingEdgeStart && elementSize < scrollingSize || elementEdgeEnd > scrollingEdgeEnd && elementSize > scrollingSize) {
if (elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize || elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize) {
return elementEdgeStart - scrollingEdgeStart - scrollingBorderStart;

@@ -36,0 +36,0 @@ }

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