scroll-into-view-if-needed
Advanced tools
Comparing version 2.2.19 to 2.2.20
@@ -50,4 +50,3 @@ import compute from 'compute-scroll-into-view'; | ||
function scrollIntoView(target, options) { | ||
var scrollingElement = document.scrollingElement || document.documentElement; | ||
var targetIsDetached = target !== scrollingElement && !scrollingElement.contains(target); | ||
var targetIsDetached = !target.ownerDocument.documentElement.contains(target); | ||
@@ -54,0 +53,0 @@ if (isOptionsObject(options) && typeof options.behavior === 'function') { |
@@ -57,4 +57,3 @@ "use strict"; | ||
function scrollIntoView(target, options) { | ||
var scrollingElement = document.scrollingElement || document.documentElement; | ||
var targetIsDetached = target !== scrollingElement && !scrollingElement.contains(target); | ||
var targetIsDetached = !target.ownerDocument.documentElement.contains(target); | ||
@@ -61,0 +60,0 @@ if (isOptionsObject(options) && typeof options.behavior === 'function') { |
@@ -11,3 +11,3 @@ { | ||
}, | ||
"version": "2.2.19", | ||
"version": "2.2.20", | ||
"main": "index.js", | ||
@@ -53,3 +53,3 @@ "module": "es/index.js", | ||
"flowgen": "1.2.3", | ||
"husky": "1.1.1", | ||
"husky": "1.1.2", | ||
"lint-staged": "7.3.0", | ||
@@ -59,5 +59,5 @@ "prettier": "1.14.3", | ||
"rimraf": "2.6.2", | ||
"rollup": "0.66.4", | ||
"rollup": "0.66.6", | ||
"rollup-plugin-babel": "4.0.3", | ||
"rollup-plugin-commonjs": "9.1.8", | ||
"rollup-plugin-commonjs": "9.2.0", | ||
"rollup-plugin-node-resolve": "3.4.0", | ||
@@ -69,3 +69,3 @@ "rollup-plugin-replace": "2.1.0", | ||
"tslint-config-prettier": "1.15.0", | ||
"typescript": "3.1.1" | ||
"typescript": "3.1.3" | ||
}, | ||
@@ -72,0 +72,0 @@ "keywords": [ |
@@ -230,4 +230,3 @@ (function (global, factory) { | ||
function scrollIntoView(target, options) { | ||
var scrollingElement = document.scrollingElement || document.documentElement; | ||
var targetIsDetached = target !== scrollingElement && !scrollingElement.contains(target); | ||
var targetIsDetached = !target.ownerDocument.documentElement.contains(target); | ||
@@ -234,0 +233,0 @@ if (isOptionsObject(options) && typeof options.behavior === 'function') { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.scrollIntoView=t()}(this,function(){"use strict";function e(e){return null!=e&&"object"==typeof 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 o=getComputedStyle(e,null);return t(o.overflowY,n)||t(o.overflowX,n)}return!1}function o(e,t,n,o,r,i,l,d){return i<e&&l>t||i>e&&l<t?0:i<=e&&d<=n||l>=t&&d>=n?i-e-o:l>t&&d<n||i<e&&d>n?l-t+r:0}var r=function(t,r){var i=r.scrollMode,l=r.block,d=r.inline,c=r.boundary,f=r.skipOverflowHiddenElements,u="function"==typeof c?c:function(e){return e!==c};if(!e(t))throw new TypeError("Invalid target");for(var a=document.scrollingElement||document.documentElement,s=[],h=t;e(h)&&u(h);){if((h=h.parentNode)===a){s.push(h);break}h===document.body&&n(h)&&!n(document.documentElement)||n(h,f)&&s.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,m=window.visualViewport?visualViewport.height:innerHeight,v=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,b=t.getBoundingClientRect(),w=b.height,y=b.width,W=b.top,E=b.right,H=b.bottom,M=b.left,k="start"===l||"nearest"===l?W:"end"===l?H:W+w/2,x="center"===d?M+y/2:"end"===d?E:M,I=[],O=0;O<s.length;O++){var T=s[O],V=T.getBoundingClientRect(),j=V.height,B=V.width,C=V.top,L=V.right,R=V.bottom,X=V.left;if("if-needed"===i&&W>=0&&M>=0&&H<=m&&E<=p&&W>=C&&H<=R&&M>=X&&E<=L)return I;var Y=getComputedStyle(T),S=parseInt(Y.borderLeftWidth,10),N=parseInt(Y.borderTopWidth,10),q=parseInt(Y.borderRightWidth,10),z=parseInt(Y.borderBottomWidth,10),A=0,D=0,F="offsetWidth"in T?T.offsetWidth-T.clientWidth-S-q:0,G="offsetHeight"in T?T.offsetHeight-T.clientHeight-N-z:0;if(a===T)A="start"===l?k:"end"===l?k-m:"nearest"===l?o(g,g+m,m,N,z,g+k,g+k+w,w):k-m/2,D="start"===d?x:"center"===d?x-p/2:"end"===d?x-p:o(v,v+p,p,S,q,v+x,v+x+y,y),A=Math.max(0,A+g),D=Math.max(0,D+v);else{A="start"===l?k-C-N:"end"===l?k-R+z+G:"nearest"===l?o(C,R,j,N,z+G,k,k+w,w):k-(C+j/2)+G/2,D="start"===d?x-X-S:"center"===d?x-(X+B/2)+F/2:"end"===d?x-L+q+F:o(X,L,B,S,q+F,x,x+y,y);var J=T.scrollLeft,K=T.scrollTop;k+=K-(A=Math.max(0,Math.min(K+A,T.scrollHeight-j+G))),x+=J-(D=Math.max(0,Math.min(J+D,T.scrollWidth-B+F)))}I.push({el:T,top:A,left:D})}return I};function i(e){return e===Object(e)&&0!==Object.keys(e).length}return function(e,t){var n=document.scrollingElement||document.documentElement,o=e!==n&&!n.contains(e);if(i(t)&&"function"==typeof t.behavior)return t.behavior(o?[]:r(e,t));if(!o){var l=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 o=e.el,r=e.top,i=e.left;o.scroll&&n?o.scroll({top:r,left:i,behavior:t}):(o.scrollTop=r,o.scrollLeft=i)})}(r(e,l),l.behavior)}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.scrollIntoView=t()}(this,function(){"use strict";function e(e){return null!=e&&"object"==typeof 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 o=getComputedStyle(e,null);return t(o.overflowY,n)||t(o.overflowX,n)}return!1}function o(e,t,n,o,r,i,l,d){return i<e&&l>t||i>e&&l<t?0:i<=e&&d<=n||l>=t&&d>=n?i-e-o:l>t&&d<n||i<e&&d>n?l-t+r:0}var r=function(t,r){var i=r.scrollMode,l=r.block,d=r.inline,c=r.boundary,f=r.skipOverflowHiddenElements,a="function"==typeof c?c:function(e){return e!==c};if(!e(t))throw new TypeError("Invalid target");for(var u=document.scrollingElement||document.documentElement,s=[],h=t;e(h)&&a(h);){if((h=h.parentNode)===u){s.push(h);break}h===document.body&&n(h)&&!n(document.documentElement)||n(h,f)&&s.push(h)}for(var p=window.visualViewport?visualViewport.width:innerWidth,m=window.visualViewport?visualViewport.height:innerHeight,v=window.scrollX||pageXOffset,g=window.scrollY||pageYOffset,b=t.getBoundingClientRect(),w=b.height,y=b.width,W=b.top,H=b.right,E=b.bottom,M=b.left,k="start"===l||"nearest"===l?W:"end"===l?E:W+w/2,x="center"===d?M+y/2:"end"===d?H:M,I=[],O=0;O<s.length;O++){var T=s[O],V=T.getBoundingClientRect(),j=V.height,B=V.width,C=V.top,L=V.right,R=V.bottom,X=V.left;if("if-needed"===i&&W>=0&&M>=0&&E<=m&&H<=p&&W>=C&&E<=R&&M>=X&&H<=L)return I;var Y=getComputedStyle(T),S=parseInt(Y.borderLeftWidth,10),D=parseInt(Y.borderTopWidth,10),N=parseInt(Y.borderRightWidth,10),q=parseInt(Y.borderBottomWidth,10),z=0,A=0,F="offsetWidth"in T?T.offsetWidth-T.clientWidth-S-N:0,G="offsetHeight"in T?T.offsetHeight-T.clientHeight-D-q:0;if(u===T)z="start"===l?k:"end"===l?k-m:"nearest"===l?o(g,g+m,m,D,q,g+k,g+k+w,w):k-m/2,A="start"===d?x:"center"===d?x-p/2:"end"===d?x-p:o(v,v+p,p,S,N,v+x,v+x+y,y),z=Math.max(0,z+g),A=Math.max(0,A+v);else{z="start"===l?k-C-D:"end"===l?k-R+q+G:"nearest"===l?o(C,R,j,D,q+G,k,k+w,w):k-(C+j/2)+G/2,A="start"===d?x-X-S:"center"===d?x-(X+B/2)+F/2:"end"===d?x-L+N+F:o(X,L,B,S,N+F,x,x+y,y);var J=T.scrollLeft,K=T.scrollTop;k+=K-(z=Math.max(0,Math.min(K+z,T.scrollHeight-j+G))),x+=J-(A=Math.max(0,Math.min(J+A,T.scrollWidth-B+F)))}I.push({el:T,top:z,left:A})}return I};function i(e){return e===Object(e)&&0!==Object.keys(e).length}return function(e,t){var n=!e.ownerDocument.documentElement.contains(e);if(i(t)&&"function"==typeof t.behavior)return t.behavior(n?[]:r(e,t));if(!n){var o=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 o=e.el,r=e.top,i=e.left;o.scroll&&n?o.scroll({top:r,left:i,behavior:t}):(o.scrollTop=r,o.scrollLeft=i)})}(r(e,o),o.behavior)}}}); |
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
44325
355