scroll-into-view
Advanced tools
Comparing version 1.13.1 to 1.14.0
{ | ||
"name": "scroll-into-view", | ||
"version": "1.13.1", | ||
"version": "1.14.0", | ||
"description": "scrolls an elements into view, recursively aligning parents.", | ||
@@ -5,0 +5,0 @@ "main": "scrollIntoView.js", |
@@ -0,0 +0,0 @@ |
@@ -56,6 +56,6 @@ var COMPLETE = 'complete', | ||
y = offsetTop + (targetHeight * topScalar) - parent.clientHeight * topScalar; | ||
x -= leftOffset; | ||
y -= topOffset; | ||
x = Math.max(Math.min(x, parent.scrollWidth - parent.clientWidth), 0); | ||
y = Math.max(Math.min(y, parent.scrollHeight - parent.clientHeight), 0); | ||
x -= leftOffset; | ||
y -= topOffset; | ||
differenceX = x - parent.scrollLeft; | ||
@@ -62,0 +62,0 @@ differenceY = y - parent.scrollTop; |
@@ -1,3 +0,3 @@ | ||
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
var COMPLETE="complete",CANCELED="canceled";function raf(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}function setElementScroll(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function getTargetScrollLocation(e,t){var n,l,i,o,r,a,s,c=e.align,f=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,u=c&&null!=c.top?c.top:.5,g=c&&null!=c.leftOffset?c.leftOffset:0,m=c&&null!=c.topOffset?c.topOffset:0,h=d,p=u;if(e.isWindow(t))a=Math.min(f.width,t.innerWidth),s=Math.min(f.height,t.innerHeight),l=f.left+t.pageXOffset-t.innerWidth*h+a*h,i=f.top+t.pageYOffset-t.innerHeight*p+s*p,i-=m,o=(l-=g)-t.pageXOffset,r=i-t.pageYOffset;else{a=f.width,s=f.height,n=t.getBoundingClientRect();var S=f.left-(n.left-t.scrollLeft),E=f.top-(n.top-t.scrollTop);l=S+a*h-t.clientWidth*h,i=E+s*p-t.clientHeight*p,l=Math.max(Math.min(l,t.scrollWidth-t.clientWidth),0),i=Math.max(Math.min(i,t.scrollHeight-t.clientHeight),0),i-=m,o=(l-=g)-t.scrollLeft,r=i-t.scrollTop}return{x:l,y:i,differenceX:o,differenceY:r}}function animate(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,l=getTargetScrollLocation(t,e),i=Date.now()-t.startTime,o=Math.min(1/t.time*i,1);if(t.endIterations>=n)return setElementScroll(e,l.x,l.y),e._scrollSettings=null,t.end(COMPLETE);var r=1-t.ease(o);if(setElementScroll(e,l.x-l.differenceX*r,l.y-l.differenceY*r),i>=t.time)return t.endIterations++,animate(e);raf(animate.bind(null,e))}}function defaultIsWindow(e){return e.self===e}function transitionScrollTo(e,t,n,l){var i,o=!t._scrollSettings,r=t._scrollSettings,a=Date.now(),s={passive:!0};function c(e){t._scrollSettings=null,t.parentElement&&t.parentElement._scrollSettings&&t.parentElement._scrollSettings.end(e),n.debug&&console.log("Scrolling ended with type",e,"for",t),l(e),i&&(t.removeEventListener("touchstart",i,s),t.removeEventListener("wheel",i,s))}r&&r.end(CANCELED);var f=n.maxSynchronousAlignments;null==f&&(f=3),t._scrollSettings={startTime:r?r.startTime:Date.now(),endIterations:0,target:e,time:n.time+(r?a-r.startTime:0),ease:n.ease,align:n.align,isWindow:n.isWindow||defaultIsWindow,maxSynchronousAlignments:f,end:c},"cancellable"in n&&!n.cancellable||(i=c.bind(null,CANCELED),t.addEventListener("touchstart",i,s),t.addEventListener("wheel",i,s)),o&&animate(t)}function defaultIsScrollable(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function defaultValidTarget(){return!0}module.exports=function(e,t,n){if(e){"function"==typeof t&&(n=t,t=null),t||(t={}),t.time=isNaN(t.time)?1e3:t.time,t.ease=t.ease||function(e){return 1-Math.pow(1-e,e/2)};var l=e.parentElement,i=1,o=t.validTarget||defaultValidTarget,r=t.isScrollable;for(t.debug&&(console.log("About to scroll to",e),l||console.error("Target did not have a parent, is it mounted in the DOM?"));l;)if("BODY"===l.tagName&&(l=(l=l.ownerDocument).defaultView||l.ownerWindow),t.debug&&console.log("Scrolling parent node",l),o(l,i)&&(r?r(l,defaultIsScrollable):defaultIsScrollable(l))&&(i++,transitionScrollTo(e,l,t,a)),!(l=l.parentElement)){a(COMPLETE);break}}function a(e){--i||n&&n(e)}}; | ||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
function raf(e){if("requestAnimationFrame"in window)return window.requestAnimationFrame(e);setTimeout(e,16)}function setElementScroll(e,t,n){e.self===e?e.scrollTo(t,n):(e.scrollLeft=t,e.scrollTop=n)}function getTargetScrollLocation(e,t){var n,l,i,o,r,a,s,c=e.align,f=e.target.getBoundingClientRect(),d=c&&null!=c.left?c.left:.5,u=c&&null!=c.top?c.top:.5,g=c&&null!=c.leftOffset?c.leftOffset:0,m=c&&null!=c.topOffset?c.topOffset:0,h=d,p=u;if(e.isWindow(t))a=Math.min(f.width,t.innerWidth),s=Math.min(f.height,t.innerHeight),l=f.left+t.pageXOffset-t.innerWidth*h+a*h,i=f.top+t.pageYOffset-t.innerHeight*p+s*p,i-=m,o=(l-=g)-t.pageXOffset,r=i-t.pageYOffset;else{a=f.width,s=f.height,n=t.getBoundingClientRect();var S=f.left-(n.left-t.scrollLeft),E=f.top-(n.top-t.scrollTop);l=S+a*h-t.clientWidth*h,i=E+s*p-t.clientHeight*p,l-=g,i-=m,l=Math.max(Math.min(l,t.scrollWidth-t.clientWidth),0),i=Math.max(Math.min(i,t.scrollHeight-t.clientHeight),0),o=l-t.scrollLeft,r=i-t.scrollTop}return{x:l,y:i,differenceX:o,differenceY:r}}function animate(e){var t=e._scrollSettings;if(t){var n=t.maxSynchronousAlignments,l=getTargetScrollLocation(t,e),i=Date.now()-t.startTime,o=Math.min(1/t.time*i,1);if(t.endIterations>=n)return setElementScroll(e,l.x,l.y),e._scrollSettings=null,t.end(COMPLETE);var r=1-t.ease(o);if(setElementScroll(e,l.x-l.differenceX*r,l.y-l.differenceY*r),i>=t.time)return t.endIterations++,animate(e);raf(animate.bind(null,e))}}function defaultIsWindow(e){return e.self===e}function transitionScrollTo(e,t,n,l){function i(e){t._scrollSettings=null,t.parentElement&&t.parentElement._scrollSettings&&t.parentElement._scrollSettings.end(e),n.debug&&console.log("Scrolling ended with type",e,"for",t),l(e),o&&(t.removeEventListener("touchstart",o,c),t.removeEventListener("wheel",o,c))}var o,r=!t._scrollSettings,a=t._scrollSettings,s=Date.now(),c={passive:!0};a&&a.end(CANCELED);var f=n.maxSynchronousAlignments;null==f&&(f=3),t._scrollSettings={startTime:a?a.startTime:Date.now(),endIterations:0,target:e,time:n.time+(a?s-a.startTime:0),ease:n.ease,align:n.align,isWindow:n.isWindow||defaultIsWindow,maxSynchronousAlignments:f,end:i},"cancellable"in n&&!n.cancellable||(o=i.bind(null,CANCELED),t.addEventListener("touchstart",o,c),t.addEventListener("wheel",o,c)),r&&animate(t)}function defaultIsScrollable(e){return"pageXOffset"in e||(e.scrollHeight!==e.clientHeight||e.scrollWidth!==e.clientWidth)&&"hidden"!==getComputedStyle(e).overflow}function defaultValidTarget(){return!0}var COMPLETE="complete",CANCELED="canceled";module.exports=function(e,t,n){function l(e){--o||n&&n(e)}if(e){"function"==typeof t&&(n=t,t=null),t||(t={}),t.time=isNaN(t.time)?1e3:t.time,t.ease=t.ease||function(e){return 1-Math.pow(1-e,e/2)};var i=e.parentElement,o=1,r=t.validTarget||defaultValidTarget,a=t.isScrollable;for(t.debug&&(console.log("About to scroll to",e),i||console.error("Target did not have a parent, is it mounted in the DOM?"));i;)if("BODY"===i.tagName&&(i=(i=i.ownerDocument).defaultView||i.ownerWindow),t.debug&&console.log("Scrolling parent node",i),r(i,o)&&(a?a(i,defaultIsScrollable):defaultIsScrollable(i))&&(o++,transitionScrollTo(e,i,t,l)),!(i=i.parentElement)){l(COMPLETE);break}}}; | ||
@@ -4,0 +4,0 @@ },{}],2:[function(require,module,exports){ |
// This file is used by `npm run build` to output scrollIntoView.min.js | ||
window.scrollIntoView = require('./scrollIntoView'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20268