Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.28 to 2.2.29

6

es/index.js

@@ -50,9 +50,9 @@ import compute from 'compute-scroll-into-view';

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;

@@ -59,0 +59,0 @@ }

@@ -57,9 +57,9 @@ "use strict";

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 ? [] : (0, _computeScrollIntoView["default"])(target, options));
return options.behavior(isTargetAttached ? (0, _computeScrollIntoView["default"])(target, options) : []);
}
if (targetIsDetached) {
if (!isTargetAttached) {
return;

@@ -66,0 +66,0 @@ }

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

},
"version": "2.2.28",
"version": "2.2.29",
"main": "index.js",

@@ -41,22 +41,22 @@ "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.10",
"@babel/preset-typescript": "7.13.0",
"@babel/cli": "7.16.7",
"@babel/core": "7.16.7",
"@babel/plugin-external-helpers": "7.16.7",
"@babel/preset-env": "7.16.7",
"@babel/preset-typescript": "7.16.7",
"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": "6.15.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-react": "7.22.0",
"flowgen": "1.13.0",
"husky": "4.3.8",
"lint-staged": "10.5.4",
"prettier": "2.2.1",
"prettier-package-json": "2.1.3",
"babel-plugin-dev-expression": "0.2.3",
"concurrently": "6.5.1",
"eslint": "8.7.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-react": "7.28.0",
"flowgen": "1.16.2",
"husky": "7.0.4",
"lint-staged": "12.3.1",
"prettier": "2.5.1",
"prettier-package-json": "2.6.0",
"rimraf": "3.0.2",
"rollup": "2.42.1",
"rollup": "2.63.0",
"rollup-plugin-babel": "4.4.0",

@@ -67,6 +67,6 @@ "rollup-plugin-commonjs": "10.1.0",

"rollup-plugin-terser": "7.0.2",
"semantic-release": "17.4.2",
"semantic-release": "17.4.7",
"tslint": "5.20.1",
"tslint-config-prettier": "1.18.0",
"typescript": "4.2.3"
"typescript": "4.5.4"
},

@@ -95,3 +95,3 @@ "keywords": [

"path": "./umd/scroll-into-view-if-needed.min.js",
"maxSize": "3.2 kB",
"maxSize": "3.3 kB",
"compression": "none"

@@ -98,0 +98,0 @@ }

@@ -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;

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