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.1.6 to 2.1.7

20

compute.js

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var isElement = function isElement(el) {

@@ -55,12 +53,10 @@ return el != null && typeof el == 'object' && el.nodeType === 1;

var _scrollMode$block$inl = _extends({
scrollMode: 'always',
block: 'center',
inline: 'nearest'
}, options),
scrollMode = _scrollMode$block$inl.scrollMode,
block = _scrollMode$block$inl.block,
inline = _scrollMode$block$inl.inline,
boundary = _scrollMode$block$inl.boundary;
var _options = options,
_options$scrollMode = _options.scrollMode,
scrollMode = _options$scrollMode === void 0 ? 'always' : _options$scrollMode,
_options$block = _options.block,
block = _options$block === void 0 ? 'center' : _options$block,
_options$inline = _options.inline,
inline = _options$inline === void 0 ? 'nearest' : _options$inline,
boundary = _options.boundary;
var checkBoundary = typeof boundary == 'function' ? boundary : function (parent) {

@@ -67,0 +63,0 @@ return parent !== boundary;

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var isElement = function isElement(el) {

@@ -49,12 +47,10 @@ return el != null && typeof el == 'object' && el.nodeType === 1;

var _scrollMode$block$inl = _extends({
scrollMode: 'always',
block: 'center',
inline: 'nearest'
}, options),
scrollMode = _scrollMode$block$inl.scrollMode,
block = _scrollMode$block$inl.block,
inline = _scrollMode$block$inl.inline,
boundary = _scrollMode$block$inl.boundary;
var _options = options,
_options$scrollMode = _options.scrollMode,
scrollMode = _options$scrollMode === void 0 ? 'always' : _options$scrollMode,
_options$block = _options.block,
block = _options$block === void 0 ? 'center' : _options$block,
_options$inline = _options.inline,
inline = _options$inline === void 0 ? 'nearest' : _options$inline,
boundary = _options.boundary;
var checkBoundary = typeof boundary == 'function' ? boundary : function (parent) {

@@ -61,0 +57,0 @@ return parent !== boundary;

7

es/index.js

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import compute from './compute';

@@ -61,6 +59,3 @@ var supportsScrollBehavior;

} else if (isOptionsObject(options)) {
return _extends({
block: 'center',
inline: 'nearest'
}, options);
return options;
}

@@ -67,0 +62,0 @@

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var supportsScrollBehavior;

@@ -70,6 +68,3 @@

} else if (isOptionsObject(options)) {
return _extends({
block: 'center',
inline: 'nearest'
}, options);
return options;
}

@@ -76,0 +71,0 @@

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

},
"version": "2.1.6",
"version": "2.1.7",
"main": "index.js",

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

"eslint-plugin-react": "7.7.0",
"flowgen": "1.2.1",
"flowgen": "1.2.2",
"husky": "0.14.3",

@@ -53,0 +53,0 @@ "lint-staged": "7.1.0",

@@ -7,20 +7,2 @@ (function (global, factory) {

function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var isElement = function isElement(el) {

@@ -72,12 +54,10 @@ return el != null && typeof el == 'object' && el.nodeType === 1;

var _scrollMode$block$inl = _extends({
scrollMode: 'always',
block: 'center',
inline: 'nearest'
}, options),
scrollMode = _scrollMode$block$inl.scrollMode,
block = _scrollMode$block$inl.block,
inline = _scrollMode$block$inl.inline,
boundary = _scrollMode$block$inl.boundary;
var _options = options,
_options$scrollMode = _options.scrollMode,
scrollMode = _options$scrollMode === void 0 ? 'always' : _options$scrollMode,
_options$block = _options.block,
block = _options$block === void 0 ? 'center' : _options$block,
_options$inline = _options.inline,
inline = _options$inline === void 0 ? 'nearest' : _options$inline,
boundary = _options.boundary;
var checkBoundary = typeof boundary == 'function' ? boundary : function (parent) {

@@ -335,6 +315,3 @@ return parent !== boundary;

} else if (isOptionsObject(options)) {
return _extends({
block: 'center',
inline: 'nearest'
}, options);
return options;
}

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