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.0.0-alpha.0 to 1.0.0-alpha.f7841b3e

.babelrc.js

4

package.json

@@ -11,8 +11,8 @@ {

},
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.f7841b3e",
"main": "index.js",
"files": [
"es",
"auto.js",
"compute.js",
"es",
"ponyfill.js",

@@ -19,0 +19,0 @@ "umd"

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.smoothScrollIntoViewIfNeeded = {})));
(factory((global.scrollIntoView = {})));
}(this, (function (exports) { 'use strict';

@@ -6,0 +6,0 @@

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

!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(o.smoothScrollIntoViewIfNeeded={})}(this,function(o){"use strict";var t=function(o){return null!=o&&"object"==typeof o&&1===o.nodeType};function e(o,t){return"Y"===t?o.clientHeight<o.scrollHeight:"X"===t&&o.clientWidth<o.scrollWidth}var l=function(o,l){void 0===l&&(l={});var n=l,r=n.scrollMode,i=void 0===r?"always":r,c=n.block,a=void 0===c?"center":c,s=n.inline,f=void 0===s?"nearest":s,d=n.boundary;if(!t(o))throw new Error("Element is required in scrollIntoViewIfNeeded");var m=o,u=m.getBoundingClientRect();console.error("scrollMode",i,"block",a,"inline",f,"boundary",d,"target",m);for(var h,g,p,v,b,w,T=[];t(h=m.parentNode)&&m!==d;)void 0,void 0,p=e(g=h,"Y"),v=e(g,"X"),(p||v)&&T.push(h),m=h;return T.map(function(o){var t=o.getBoundingClientRect(),e=0,l=0;if("start"===a)if(b||(b=u.top),document.documentElement===o)e=o.scrollTop+b;else{var n=Math.min(b-t.top,o.scrollHeight-o.clientHeight-o.scrollTop);e=o.scrollTop+n,b-=e-o.scrollTop,console.log("targetBlock",b,"scrollMode",i)}if("center"===a)if(b||(b=u.top+u.height/2),document.documentElement===o)e=o.scrollTop+b-o.clientHeight/2;else{var r=0-Math.min(t.top+t.height/2-b,o.scrollTop);e=o.scrollTop+r,b+=o.scrollTop-e}if("end"===a)if(b||(b=u.bottom),document.documentElement===o)e=o.scrollTop+b-o.clientHeight;else{var c=0-Math.min(t.bottom-b,o.scrollTop);e=o.scrollTop+c,b+=o.scrollTop-e}if("nearest"===a)if(b||(b=u.top),document.documentElement===o);else{console.group("alignNearestBlock");var s=function(o,t,e,l){var n=o+t;return o>=l.top&&n<=l.bottom?(console.warn("bail",o,l.top),0):(console.warn("top","target",o,"frame",l.top,l.width,e.clientWidth,o<l.top),console.warn("bottom","target",n,"frame",l.bottom,n>l.bottom),o<l.top&&t<e.clientHeight||n>l.bottom&&t>e.clientHeight?(console.log("align to start",o,l.top),o-l.top):n>l.bottom&&t<e.clientHeight||o<l.top&&t>e.clientHeight?(console.log("align to end",o,l.top),o-l.top):(console.log("alignToNearest","targetStart",o,"should be 33 if clicking on 1",Math.min(o,Math.max(n-e.clientHeight,e.scrollTop))),console.error("failure?",o,e),0))}(b,u.height,o,t);console.groupEnd(),e=o.scrollTop+s,b-=s}if("start"===f)if(w||(w=u.left),document.documentElement===o)l=o.scrollLeft+w;else{var d=Math.min(w-t.left,o.scrollLeft-o.clientLeft-o.scrollLeft);l=o.scrollLeft+d,w-=l-o.scrollLeft}if("center"===f)if(w||(w=u.left+u.width/2),document.documentElement===o)l=o.scrollLeft+w-o.clientLeft/2;else{var m=0-Math.min(t.left+t.width/2-w,o.scrollLeft);l=o.scrollLeft+m,w+=o.scrollLeft-l}if("end"===f)if(w||(w=u.bottom),document.documentElement===o)l=o.scrollLeft+w-o.clientLeft;else{var h=0-Math.min(t.bottom-w,o.scrollLeft);l=o.scrollLeft+h,w+=o.scrollLeft-l}if("nearest"===f)if(w||(w=u.left),document.documentElement===o);else{console.group("alignNearestInline");var g=function(o,t,e,l){var n=o+t;return o>=l.left&&n<=l.right?(console.warn("bail",o,l.left),0):(console.warn("left","target",o,"frame",l.left,l.width,e.clientWidth,o<l.left),console.warn("right","target",n,"frame",l.right,n>l.right),o<l.left&&t<e.clientWidth||n>l.right&&t>e.clientWidth?(console.log("align to start",o,l.left),o-l.left):n>l.right&&t<e.clientWidth||o<l.left&&t>e.clientWidth?(console.log("align to end",o,l.left),o-l.left):(console.log("alignToNearest","targetStart",o,"should be 33 if clicking on 1",Math.min(o,Math.max(n-e.clientWidth,e.scrollTop))),console.error("failure?",o,e),0))}(w,u.width,o,t);console.groupEnd(),l=o.scrollLeft+g,w-=g}return[o,e,l]})},n=function(o,t){void 0===t&&(t={});var e=t.behavior,n=void 0===e?"auto":e,r=l(o,t);r&&r.forEach(function(o){var t=o[0],e=o[1],l=o[2];t.scroll?(console.log("hmmmmmmmmm"),t.scroll({top:e,left:l,behavior:n})):(console.log("oh oh oh"),t.scrollTop=e,t.scrollLeft=l)})},r="performance"in global?performance.now.bind(performance):Date.now,i=468;function c(o){var t,e,l,n,a=(r()-o.startTime)/i;n=a=a>1?1:a,t=.5*(1-Math.cos(Math.PI*n)),e=o.startX+(o.x-o.startX)*t,l=o.startY+(o.y-o.startY)*t,o.method.call(o.scrollable,e,l),e===o.x&&l===o.y||requestAnimationFrame(c.bind(global,o))}o.default=n,o.auto=n,o.ponyfill=function(o,t){var e=t.behavior,n=void 0===e?"auto":e;console.log("behavior",n,t);var i=l(o,t);return Promise.all(i.map(function(o){var t=o[0],e=o[1],l=o[2];return new Promise(function(o){!function(o,t,e,l){var n,i,a,s,f=r();o===document.body||o===document.documentElement?(n=window,i=window.scrollX||window.pageXOffset,a=window.scrollY||window.pageYOffset,s=window.scroll,console.error("damn")):(n=o,i=o.scrollLeft,a=o.scrollTop,s=function(t,e){console.error("x",t,"y",e),o.scrollLeft=t,o.scrollTop=e}),c({scrollable:n,method:s,startTime:f,startX:i,startY:a,x:t,y:e,cb:l})}(t,l,e,function(){return o()})})}))},o.compute=l,Object.defineProperty(o,"__esModule",{value:!0})});
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(o.scrollIntoView={})}(this,function(o){"use strict";var t=function(o){return null!=o&&"object"==typeof o&&1===o.nodeType};function e(o,t){return"Y"===t?o.clientHeight<o.scrollHeight:"X"===t&&o.clientWidth<o.scrollWidth}var l=function(o,l){void 0===l&&(l={});var n=l,r=n.scrollMode,i=void 0===r?"always":r,c=n.block,a=void 0===c?"center":c,s=n.inline,f=void 0===s?"nearest":s,d=n.boundary;if(!t(o))throw new Error("Element is required in scrollIntoViewIfNeeded");var m=o,u=m.getBoundingClientRect();console.error("scrollMode",i,"block",a,"inline",f,"boundary",d,"target",m);for(var h,g,p,v,b,w,T=[];t(h=m.parentNode)&&m!==d;)void 0,void 0,p=e(g=h,"Y"),v=e(g,"X"),(p||v)&&T.push(h),m=h;return T.map(function(o){var t=o.getBoundingClientRect(),e=0,l=0;if("start"===a)if(b||(b=u.top),document.documentElement===o)e=o.scrollTop+b;else{var n=Math.min(b-t.top,o.scrollHeight-o.clientHeight-o.scrollTop);e=o.scrollTop+n,b-=e-o.scrollTop,console.log("targetBlock",b,"scrollMode",i)}if("center"===a)if(b||(b=u.top+u.height/2),document.documentElement===o)e=o.scrollTop+b-o.clientHeight/2;else{var r=0-Math.min(t.top+t.height/2-b,o.scrollTop);e=o.scrollTop+r,b+=o.scrollTop-e}if("end"===a)if(b||(b=u.bottom),document.documentElement===o)e=o.scrollTop+b-o.clientHeight;else{var c=0-Math.min(t.bottom-b,o.scrollTop);e=o.scrollTop+c,b+=o.scrollTop-e}if("nearest"===a)if(b||(b=u.top),document.documentElement===o);else{console.group("alignNearestBlock");var s=function(o,t,e,l){var n=o+t;return o>=l.top&&n<=l.bottom?(console.warn("bail",o,l.top),0):(console.warn("top","target",o,"frame",l.top,l.width,e.clientWidth,o<l.top),console.warn("bottom","target",n,"frame",l.bottom,n>l.bottom),o<l.top&&t<e.clientHeight||n>l.bottom&&t>e.clientHeight?(console.log("align to start",o,l.top),o-l.top):n>l.bottom&&t<e.clientHeight||o<l.top&&t>e.clientHeight?(console.log("align to end",o,l.top),o-l.top):(console.log("alignToNearest","targetStart",o,"should be 33 if clicking on 1",Math.min(o,Math.max(n-e.clientHeight,e.scrollTop))),console.error("failure?",o,e),0))}(b,u.height,o,t);console.groupEnd(),e=o.scrollTop+s,b-=s}if("start"===f)if(w||(w=u.left),document.documentElement===o)l=o.scrollLeft+w;else{var d=Math.min(w-t.left,o.scrollLeft-o.clientLeft-o.scrollLeft);l=o.scrollLeft+d,w-=l-o.scrollLeft}if("center"===f)if(w||(w=u.left+u.width/2),document.documentElement===o)l=o.scrollLeft+w-o.clientLeft/2;else{var m=0-Math.min(t.left+t.width/2-w,o.scrollLeft);l=o.scrollLeft+m,w+=o.scrollLeft-l}if("end"===f)if(w||(w=u.bottom),document.documentElement===o)l=o.scrollLeft+w-o.clientLeft;else{var h=0-Math.min(t.bottom-w,o.scrollLeft);l=o.scrollLeft+h,w+=o.scrollLeft-l}if("nearest"===f)if(w||(w=u.left),document.documentElement===o);else{console.group("alignNearestInline");var g=function(o,t,e,l){var n=o+t;return o>=l.left&&n<=l.right?(console.warn("bail",o,l.left),0):(console.warn("left","target",o,"frame",l.left,l.width,e.clientWidth,o<l.left),console.warn("right","target",n,"frame",l.right,n>l.right),o<l.left&&t<e.clientWidth||n>l.right&&t>e.clientWidth?(console.log("align to start",o,l.left),o-l.left):n>l.right&&t<e.clientWidth||o<l.left&&t>e.clientWidth?(console.log("align to end",o,l.left),o-l.left):(console.log("alignToNearest","targetStart",o,"should be 33 if clicking on 1",Math.min(o,Math.max(n-e.clientWidth,e.scrollTop))),console.error("failure?",o,e),0))}(w,u.width,o,t);console.groupEnd(),l=o.scrollLeft+g,w-=g}return[o,e,l]})},n=function(o,t){void 0===t&&(t={});var e=t.behavior,n=void 0===e?"auto":e,r=l(o,t);r&&r.forEach(function(o){var t=o[0],e=o[1],l=o[2];t.scroll?(console.log("hmmmmmmmmm"),t.scroll({top:e,left:l,behavior:n})):(console.log("oh oh oh"),t.scrollTop=e,t.scrollLeft=l)})},r="performance"in global?performance.now.bind(performance):Date.now,i=468;function c(o){var t,e,l,n,a=(r()-o.startTime)/i;n=a=a>1?1:a,t=.5*(1-Math.cos(Math.PI*n)),e=o.startX+(o.x-o.startX)*t,l=o.startY+(o.y-o.startY)*t,o.method.call(o.scrollable,e,l),e===o.x&&l===o.y||requestAnimationFrame(c.bind(global,o))}o.default=n,o.auto=n,o.ponyfill=function(o,t){var e=t.behavior,n=void 0===e?"auto":e;console.log("behavior",n,t);var i=l(o,t);return Promise.all(i.map(function(o){var t=o[0],e=o[1],l=o[2];return new Promise(function(o){!function(o,t,e,l){var n,i,a,s,f=r();o===document.body||o===document.documentElement?(n=window,i=window.scrollX||window.pageXOffset,a=window.scrollY||window.pageYOffset,s=window.scroll,console.error("damn")):(n=o,i=o.scrollLeft,a=o.scrollTop,s=function(t,e){console.error("x",t,"y",e),o.scrollLeft=t,o.scrollTop=e}),c({scrollable:n,method:s,startTime:f,startX:i,startY:a,x:t,y:e,cb:l})}(t,l,e,function(){return o()})})}))},o.compute=l,Object.defineProperty(o,"__esModule",{value:!0})});
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