Socket
Socket
Sign inDemoInstall

smooth-scroll-into-view-if-needed

Package Overview
Dependencies
2
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.29 to 1.1.30

42

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"author": "Stian Didriksen",
"author": "Cody Olsen",
"homepage": "https://scroll-into-view-if-needed.netlify.com/",

@@ -12,3 +12,3 @@ "repository": {

},
"version": "1.1.29",
"version": "1.1.30",
"main": "index.js",

@@ -40,24 +40,24 @@ "module": "es/index.js",

"devDependencies": {
"@babel/cli": "7.10.5",
"@babel/core": "7.11.4",
"@babel/plugin-external-helpers": "7.10.4",
"@babel/preset-env": "7.11.0",
"@babel/preset-typescript": "7.10.4",
"@babel/cli": "7.12.10",
"@babel/core": "7.12.10",
"@babel/plugin-external-helpers": "7.12.1",
"@babel/preset-env": "7.12.11",
"@babel/preset-typescript": "7.12.7",
"@types/jest": "24.0.25",
"babel-eslint": "10.1.0",
"babel-plugin-add-module-exports": "1.0.2",
"babel-plugin-add-module-exports": "1.0.4",
"babel-plugin-dev-expression": "0.2.2",
"concurrently": "5.3.0",
"eslint": "6.8.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-react": "7.20.6",
"husky": "4.2.5",
"jest": "24.9.0",
"jest-junit": "10.0.0",
"lint-staged": "10.2.13",
"prettier": "1.19.1",
"eslint": "7.18.0",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-react": "7.22.0",
"husky": "4.3.8",
"jest": "26.6.3",
"jest-junit": "12.0.0",
"lint-staged": "10.5.3",
"prettier": "2.2.1",
"prettier-package-json": "2.1.3",
"rimraf": "3.0.2",
"rollup": "1.29.0",
"rollup": "2.36.2",
"rollup-plugin-babel": "4.4.0",

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

"rollup-plugin-replace": "2.2.0",
"rollup-plugin-terser": "5.3.0",
"semantic-release": "15.14.0",
"ts-jest": "24.3.0",
"rollup-plugin-terser": "7.0.2",
"semantic-release": "17.3.3",
"ts-jest": "26.4.4",
"typescript": "3.5.3"

@@ -72,0 +72,0 @@ },

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.scrollIntoView = factory());
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.scrollIntoView = factory());
}(this, (function () { 'use strict';
function t(t){return null!=t&&"object"==typeof 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.parentNode)===f){s.push(p);break}p===document.body&&n(p)&&!n(document.documentElement)||n(p,a)&&s.push(p);}for(var g=o.visualViewport?o.visualViewport.width:innerWidth,m=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,M=W.right,E=W.bottom,V=W.left,x="start"===d||"nearest"===d?y:"end"===d?E:y+b/2,I="center"===u?V+H/2:"end"===u?M: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&&E<=m&&M<=g&&y>=R&&E<=Y&&V>=L&&M<=X)return C;var S=getComputedStyle(k),j=parseInt(S.borderLeftWidth,10),N=parseInt(S.borderTopWidth,10),q=parseInt(S.borderRightWidth,10),z=parseInt(S.borderBottomWidth,10),A=0,F=0,G="offsetWidth"in k?k.offsetWidth-k.clientWidth-j-q:0,J="offsetHeight"in k?k.offsetHeight-k.clientHeight-N-z:0;if(f===k)A="start"===d?x:"end"===d?x-m:"nearest"===d?r(v,v+m,m,N,z,v+x,v+x+b,b):x-m/2,F="start"===u?I:"center"===u?I-g/2:"end"===u?I-g:r(w,w+g,g,j,q,w+I,w+I+H,H),A=Math.max(0,A+v),F=Math.max(0,F+w);else{A="start"===d?x-R-N:"end"===d?x-Y+z+J:"nearest"===d?r(R,Y,D,N,z+J,x,x+b,b):x-(R+D/2)+J/2,F="start"===u?I-L-j:"center"===u?I-(L+O/2)+G/2:"end"===u?I-X+q+G:r(L,X,O,j,q+G,I,I+H,H);var K=k.scrollLeft,P=k.scrollTop;x+=P-(A=Math.max(0,Math.min(P+A,k.scrollHeight-D+J))),I+=K-(F=Math.max(0,Math.min(K+F,k.scrollWidth-O+G)));}C.push({el:k,top:A,left:F});}return C}
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}

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc