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.10 to 2.2.11

2

es/index.js

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

import compute from './compute';
import compute from 'compute-scroll-into-view';

@@ -3,0 +3,0 @@ function isOptionsObject(options) {

@@ -6,3 +6,3 @@ "use strict";

var _compute = _interopRequireDefault(require("./compute"));
var _computeScrollIntoView = _interopRequireDefault(require("compute-scroll-into-view"));

@@ -59,7 +59,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

if (isOptionsObject(options) && typeof options.behavior === 'function') {
return options.behavior((0, _compute.default)(target, options));
return options.behavior((0, _computeScrollIntoView.default)(target, options));
}
var computeOptions = getOptions(options);
return defaultBehavior((0, _compute.default)(target, computeOptions), computeOptions.behavior);
return defaultBehavior((0, _computeScrollIntoView.default)(target, computeOptions), computeOptions.behavior);
}

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

@@ -11,7 +11,6 @@ {

},
"version": "2.2.10",
"version": "2.2.11",
"main": "index.js",
"module": "es/index.js",
"files": [
"compute.js",
"es",

@@ -36,2 +35,5 @@ "typings",

},
"dependencies": {
"compute-scroll-into-view": "1.0.2"
},
"devDependencies": {

@@ -38,0 +40,0 @@ "@babel/cli": "7.0.0-beta.51",

@@ -197,2 +197,4 @@ [![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/scroll-into-view-if-needed.svg?style=flat-square)](https://circleci.com/gh/stipsan/scroll-into-view-if-needed)

> If you only need the custom behavior you might be better off by using the compute library directly: https://github.com/stipsan/compute-scroll-into-view
#### block

@@ -422,2 +424,3 @@

- [compute-scroll-into-view](http://npmjs.com/package/compute-scroll-into-view) - the engine used by this library.
- [smooth-scroll-into-view-if-needed](http://npmjs.com/package/smooth-scroll-into-view-if-needed) – ponyfills smooth scrolling.

@@ -424,0 +427,0 @@ - [react-scroll-into-view-if-needed](https://www.npmjs.com/package/react-scroll-into-view-if-needed) – A thin wrapper to scroll your component into view.

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

if (!isElement(target)) {
throw new Error('Element is required in scrollIntoView');
throw new TypeError('Invalid target');
}

@@ -104,4 +104,4 @@

if (scrollMode === 'if-needed') {
if (frame === scrollingElement ? targetBottom <= viewportHeight && targetTop >= 0 && targetLeft <= viewportWidth && targetRight >= 0 : targetTop >= top && targetBottom <= bottom) {
if (scrollMode === 'if-needed' && targetTop >= 0 && targetRight >= 0) {
if (frame === scrollingElement ? targetBottom <= viewportHeight && targetLeft <= viewportWidth : targetTop >= top && targetBottom <= bottom) {
return computations;

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc