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

smooth-scroll-into-view-if-needed

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 1.1.11 to 1.1.12

4

package.json

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

},
"version": "1.1.11",
"version": "1.1.12",
"main": "index.js",

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

"dependencies": {
"scroll-into-view-if-needed": "2.2.10"
"scroll-into-view-if-needed": "2.2.11"
},

@@ -38,0 +38,0 @@ "devDependencies": {

@@ -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(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(t){return null!=t&&"object"==typeof t&&(1===t.nodeType||11===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)}return!1}function r(t,e,n,r,o,i,l,a){return i<t&&l>e||i>t&&l<e?0:i<t&&a<n||l>e&&a>n?i-t-r:l>e&&a<n||i<t&&a>n?l-e+o:0}var o,i=function(e,o){var i=o.scrollMode,l=o.block,a=o.inline,c=o.boundary,u=o.skipOverflowHiddenElements,s="function"==typeof c?c:function(t){return t!==c};if(!t(e))throw new Error("Element is required in scrollIntoView");for(var f=document.scrollingElement||document.documentElement,d=[],h=e;t(h)&&s(h);){if((h=h.parentNode||h.host)===f){d.push(h);break}n(h,u)&&d.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,v=window.visualViewport?visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,w=e.getBoundingClientRect(),g=w.height,y=w.width,W=w.top,T=w.right,k=w.bottom,H=w.left,M="start"===l||"nearest"===l?W:"end"===l?k:W+g/2,x="center"===a?H+y/2:"end"===a?T:H,E=[],I=0;I<d.length;I++){var V=d[I],X=V.getBoundingClientRect(),Y=X.height,L=X.width,O=X.top,j=X.right,B=X.bottom,C=X.left;if("if-needed"===i&&(V===f?k<=v&&W>=0&&H<=p&&T>=0:W>=O&&k<=B))return E;var R=getComputedStyle(V),q=parseInt(R.borderLeftWidth,10),P=parseInt(R.borderTopWidth,10),S=parseInt(R.borderRightWidth,10),A=parseInt(R.borderBottomWidth,10),D=0,F=0,N="offsetWidth"in V?V.offsetWidth-V.clientWidth-q-S:0,z="offsetHeight"in V?V.offsetHeight-V.clientHeight-P-A:0;if(f===V)D="start"===l?M:"end"===l?M-v:"nearest"===l?r(b,b+v,v,P,A,b+M,b+M+g,g):M-v/2,F="start"===a?x:"center"===a?x-p/2:"end"===a?x-p:r(m,m+p,p,q,S,m+x,m+x+y,y),D+=b,F+=m;else{D="start"===l?M-O-P:"end"===l?M-B+A+z:"nearest"===l?r(O,B,Y,P,A+z,M,M+g,g):M-(O+Y/2)+z/2,F="start"===a?x-C-q:"center"===a?x-(C+L/2)+N/2:"end"===a?x-j+S+N:r(C,j,L,q,S+N,x,x+y,y);var G=V.scrollLeft,J=V.scrollTop;M+=J-(D=Math.max(0,Math.min(J+D,V.scrollHeight-Y+z))),x+=G-(F=Math.max(0,Math.min(G+F,V.scrollWidth-L+N)))}E.push({el:V,top:D,left:F})}return E};function l(t){return t===Object(t)&&0!==Object.keys(t).length}function a(t,e){if(l(e)&&"function"==typeof e.behavior)return e.behavior(i(t,e));var n=function(t){return!1===t?{block:"end",inline:"nearest"}:l(t)?t:{block:"start",inline:"nearest"}}(e);return function(t,e){void 0===e&&(e="auto");var n="scrollBehavior"in document.body.style;t.forEach(function(t){var r=t.el,o=t.top,i=t.left;r.scroll&&n?r.scroll({top:o,left:i,behavior:e}):(r.scrollTop=o,r.scrollLeft=i)})}(i(t,n),n.behavior)}var c=function(){return o||(o="performance"in window?performance.now.bind(performance):Date.now),o()};function u(t,e,n,r,o,i){var l,a,u;void 0===r&&(r=600),void 0===o&&(o=function(t){return 1+--t*t*t*t*t}),l=t,a=t.scrollLeft,u=t.scrollTop,function t(e){var n=c(),r=Math.min((n-e.startTime)/e.duration,1),o=e.ease(r),i=e.startX+(e.x-e.startX)*o,l=e.startY+(e.y-e.startY)*o;e.method(i,l),i===e.x&&l===e.y||requestAnimationFrame(function(){return t(e)})}({scrollable:l,method:function(e,n){t.scrollLeft=e,t.scrollTop=n},startTime:c(),startX:a,startY:u,x:e,y:n,duration:r,ease:o,cb:i})}var s=function(t){return t&&!t.behavior||"smooth"===t.behavior};return function(t,e){if(s(e)){var n=e||{};return a(t,{block:n.block,inline:n.inline,scrollMode:n.scrollMode,boundary:n.boundary,behavior:function(t){return Promise.all(t.map(function(t){var e=t.el,r=t.left,o=t.top;return new Promise(function(t){return u(e,r,o,n.duration,n.ease,function(){return t()})})}))}})}return a(t,e)}});
!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(t){return null!=t&&"object"==typeof t&&(1===t.nodeType||11===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)}return!1}function r(t,e,n,r,o,i,l,a){return i<t&&l>e||i>t&&l<e?0:i<t&&a<n||l>e&&a>n?i-t-r:l>e&&a<n||i<t&&a>n?l-e+o:0}var o,i=function(e,o){var i=o.scrollMode,l=o.block,a=o.inline,c=o.boundary,u=o.skipOverflowHiddenElements,f="function"==typeof c?c:function(t){return t!==c};if(!t(e))throw new TypeError("Invalid target");for(var s=document.scrollingElement||document.documentElement,d=[],h=e;t(h)&&f(h);){if((h=h.parentNode||h.host)===s){d.push(h);break}n(h,u)&&d.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,v=window.visualViewport?visualViewport.height:innerHeight,m=window.scrollX||pageXOffset,b=window.scrollY||pageYOffset,w=e.getBoundingClientRect(),g=w.height,y=w.width,W=w.top,T=w.right,k=w.bottom,H=w.left,M="start"===l||"nearest"===l?W:"end"===l?k:W+g/2,x="center"===a?H+y/2:"end"===a?T:H,I=[],X=0;X<d.length;X++){var Y=d[X],E=Y.getBoundingClientRect(),L=E.height,O=E.width,V=E.top,j=E.right,B=E.bottom,C=E.left;if("if-needed"===i&&W>=0&&T>=0&&(Y===s?k<=v&&H<=p:W>=V&&k<=B))return I;var R=getComputedStyle(Y),P=parseInt(R.borderLeftWidth,10),S=parseInt(R.borderTopWidth,10),q=parseInt(R.borderRightWidth,10),A=parseInt(R.borderBottomWidth,10),D=0,F=0,N="offsetWidth"in Y?Y.offsetWidth-Y.clientWidth-P-q:0,z="offsetHeight"in Y?Y.offsetHeight-Y.clientHeight-S-A:0;if(s===Y)D="start"===l?M:"end"===l?M-v:"nearest"===l?r(b,b+v,v,S,A,b+M,b+M+g,g):M-v/2,F="start"===a?x:"center"===a?x-p/2:"end"===a?x-p:r(m,m+p,p,P,q,m+x,m+x+y,y),D+=b,F+=m;else{D="start"===l?M-V-S:"end"===l?M-B+A+z:"nearest"===l?r(V,B,L,S,A+z,M,M+g,g):M-(V+L/2)+z/2,F="start"===a?x-C-P:"center"===a?x-(C+O/2)+N/2:"end"===a?x-j+q+N:r(C,j,O,P,q+N,x,x+y,y);var G=Y.scrollLeft,J=Y.scrollTop;M+=J-(D=Math.max(0,Math.min(J+D,Y.scrollHeight-L+z))),x+=G-(F=Math.max(0,Math.min(G+F,Y.scrollWidth-O+N)))}I.push({el:Y,top:D,left:F})}return I};function l(t){return t===Object(t)&&0!==Object.keys(t).length}function a(t,e){if(l(e)&&"function"==typeof e.behavior)return e.behavior(i(t,e));var n=function(t){return!1===t?{block:"end",inline:"nearest"}:l(t)?t:{block:"start",inline:"nearest"}}(e);return function(t,e){void 0===e&&(e="auto");var n="scrollBehavior"in document.body.style;t.forEach(function(t){var r=t.el,o=t.top,i=t.left;r.scroll&&n?r.scroll({top:o,left:i,behavior:e}):(r.scrollTop=o,r.scrollLeft=i)})}(i(t,n),n.behavior)}var c=function(){return o||(o="performance"in window?performance.now.bind(performance):Date.now),o()};function u(t,e,n,r,o,i){var l,a,u;void 0===r&&(r=600),void 0===o&&(o=function(t){return 1+--t*t*t*t*t}),l=t,a=t.scrollLeft,u=t.scrollTop,function t(e){var n=c(),r=Math.min((n-e.startTime)/e.duration,1),o=e.ease(r),i=e.startX+(e.x-e.startX)*o,l=e.startY+(e.y-e.startY)*o;e.method(i,l),i===e.x&&l===e.y||requestAnimationFrame(function(){return t(e)})}({scrollable:l,method:function(e,n){t.scrollLeft=e,t.scrollTop=n},startTime:c(),startX:a,startY:u,x:e,y:n,duration:r,ease:o,cb:i})}var f=function(t){return t&&!t.behavior||"smooth"===t.behavior};return function(t,e){if(f(e)){var n=e||{};return a(t,{block:n.block,inline:n.inline,scrollMode:n.scrollMode,boundary:n.boundary,behavior:function(t){return Promise.all(t.map(function(t){var e=t.el,r=t.left,o=t.top;return new Promise(function(t){return u(e,r,o,n.duration,n.ease,function(){return t()})})}))}})}return a(t,e)}});
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