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.15 to 1.1.16

5

es/index.js

@@ -72,4 +72,5 @@ import scrollIntoView from 'scroll-into-view-if-needed';

function scroll(target, options) {
if (shouldSmoothScroll(options)) {
var overrides = options || {};
var overrides = options || {};
if (shouldSmoothScroll(overrides)) {
return scrollIntoView(target, {

@@ -76,0 +77,0 @@ block: overrides.block,

@@ -80,4 +80,5 @@ "use strict";

function scroll(target, options) {
if (shouldSmoothScroll(options)) {
var overrides = options || {};
var overrides = options || {};
if (shouldSmoothScroll(overrides)) {
return (0, _scrollIntoViewIfNeeded.default)(target, {

@@ -84,0 +85,0 @@ block: overrides.block,

30

package.json

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

},
"version": "1.1.15",
"version": "1.1.16",
"main": "index.js",

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

"prepublishOnly": "unset npm_config_cafile && yarn build",
"test": "jest",
"typecheck": "tsc --noEmit"

@@ -44,2 +45,3 @@ },

"@babel/preset-typescript": "7.0.0-beta.54",
"@types/jest": "23.3.0",
"babel-eslint": "8.2.6",

@@ -54,2 +56,4 @@ "babel-plugin-add-module-exports": "0.2.1",

"husky": "0.14.3",
"jest": "23.4.1",
"jest-junit": "5.1.0",
"lint-staged": "7.2.0",

@@ -66,2 +70,3 @@ "prettier": "1.13.7",

"semantic-release": "15.8.0",
"ts-jest": "23.0.1",
"typescript": "2.9.2"

@@ -95,2 +100,25 @@ },

],
"jest": {
"transform": {
"^.+\\.ts$": "ts-jest"
},
"testRegex": "(/tests/.*|(\\.|/)(test|spec))\\.(js|ts)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"reporters": [
"default",
[
"jest-junit",
{
"output": "reports/jest/results.xml"
}
]
]
},
"lint-staged": {

@@ -97,0 +125,0 @@ "*.js": [

@@ -304,4 +304,5 @@ (function (global, factory) {

function scroll(target, options) {
if (shouldSmoothScroll(options)) {
var overrides = options || {};
var overrides = options || {};
if (shouldSmoothScroll(overrides)) {
return scrollIntoView(target, {

@@ -308,0 +309,0 @@ block: overrides.block,

@@ -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,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&&H>=0&&k<=v&&T<=p&&W>=V&&k<=B&&H>=C&&T<=j)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)}):e.cb()}({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)}});
!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 TypeError("Invalid target");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,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&&H>=0&&k<=v&&T<=p&&W>=V&&k<=B&&H>=C&&T<=j)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(f===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)}):e.cb()}({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){var n=e||{};return s(n)?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()})})}))}}):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