react-scroll-into-view-if-needed
Advanced tools
Comparing version 2.1.5 to 2.1.6
@@ -1,2 +0,2 @@ | ||
{"/Users/justin/Documents/opensource/react-scroll-into-view-if-needed/src/index.js": {"path":"/Users/justin/Documents/opensource/react-scroll-into-view-if-needed/src/index.js","statementMap":{"0":{"start":{"line":55,"column":4},"end":{"line":55,"column":12}},"1":{"start":{"line":56,"column":4},"end":{"line":56,"column":28}},"2":{"start":{"line":60,"column":23},"end":{"line":60,"column":33}},"3":{"start":{"line":61,"column":4},"end":{"line":63,"column":5}},"4":{"start":{"line":62,"column":6},"end":{"line":62,"column":42}},"5":{"start":{"line":67,"column":36},"end":{"line":67,"column":46}},"6":{"start":{"line":68,"column":4},"end":{"line":70,"column":5}},"7":{"start":{"line":69,"column":6},"end":{"line":69,"column":42}},"8":{"start":{"line":74,"column":24},"end":{"line":74,"column":34}},"9":{"start":{"line":75,"column":30},"end":{"line":75,"column":39}},"10":{"start":{"line":76,"column":4},"end":{"line":76,"column":42}},"11":{"start":{"line":86,"column":8},"end":{"line":86,"column":18}},"12":{"start":{"line":87,"column":4},"end":{"line":87,"column":85}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":54,"column":2},"end":{"line":54,"column":3}},"loc":{"start":{"line":54,"column":16},"end":{"line":57,"column":3}},"line":54},"1":{"name":"(anonymous_1)","decl":{"start":{"line":59,"column":2},"end":{"line":59,"column":3}},"loc":{"start":{"line":59,"column":22},"end":{"line":64,"column":3}},"line":59},"2":{"name":"(anonymous_2)","decl":{"start":{"line":66,"column":2},"end":{"line":66,"column":3}},"loc":{"start":{"line":66,"column":33},"end":{"line":71,"column":3}},"line":66},"3":{"name":"(anonymous_3)","decl":{"start":{"line":73,"column":33},"end":{"line":73,"column":34}},"loc":{"start":{"line":73,"column":39},"end":{"line":77,"column":3}},"line":73},"4":{"name":"(anonymous_4)","decl":{"start":{"line":79,"column":2},"end":{"line":79,"column":3}},"loc":{"start":{"line":79,"column":11},"end":{"line":88,"column":3}},"line":79}},"branchMap":{"0":{"loc":{"start":{"line":61,"column":4},"end":{"line":63,"column":5}},"type":"if","locations":[{"start":{"line":61,"column":4},"end":{"line":63,"column":5}},{"start":{"line":61,"column":4},"end":{"line":63,"column":5}}],"line":61},"1":{"loc":{"start":{"line":68,"column":4},"end":{"line":70,"column":5}},"type":"if","locations":[{"start":{"line":68,"column":4},"end":{"line":70,"column":5}},{"start":{"line":68,"column":4},"end":{"line":70,"column":5}}],"line":68},"2":{"loc":{"start":{"line":68,"column":8},"end":{"line":68,"column":30}},"type":"binary-expr","locations":[{"start":{"line":68,"column":8},"end":{"line":68,"column":15}},{"start":{"line":68,"column":19},"end":{"line":68,"column":30}}],"line":68}},"s":{"0":6,"1":6,"2":6,"3":6,"4":4,"5":2,"6":2,"7":1,"8":5,"9":5,"10":5,"11":8,"12":8},"f":{"0":6,"1":6,"2":2,"3":5,"4":8},"b":{"0":[4,2],"1":[1,1],"2":[2,2]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"8fb7f45e5d341cbe456fd202339132c85e523836"} | ||
{"/Users/justinschrader/Desktop/KOAN/opensource/react-scroll-into-view-if-needed/src/index.js": {"path":"/Users/justinschrader/Desktop/KOAN/opensource/react-scroll-into-view-if-needed/src/index.js","statementMap":{"0":{"start":{"line":55,"column":4},"end":{"line":55,"column":12}},"1":{"start":{"line":56,"column":4},"end":{"line":56,"column":28}},"2":{"start":{"line":60,"column":23},"end":{"line":60,"column":33}},"3":{"start":{"line":61,"column":4},"end":{"line":63,"column":5}},"4":{"start":{"line":62,"column":6},"end":{"line":62,"column":42}},"5":{"start":{"line":67,"column":36},"end":{"line":67,"column":46}},"6":{"start":{"line":68,"column":4},"end":{"line":70,"column":5}},"7":{"start":{"line":69,"column":6},"end":{"line":69,"column":42}},"8":{"start":{"line":74,"column":24},"end":{"line":74,"column":34}},"9":{"start":{"line":75,"column":30},"end":{"line":75,"column":39}},"10":{"start":{"line":76,"column":4},"end":{"line":76,"column":42}},"11":{"start":{"line":86,"column":8},"end":{"line":86,"column":18}},"12":{"start":{"line":87,"column":4},"end":{"line":87,"column":85}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":54,"column":2},"end":{"line":54,"column":3}},"loc":{"start":{"line":54,"column":16},"end":{"line":57,"column":3}},"line":54},"1":{"name":"(anonymous_1)","decl":{"start":{"line":59,"column":2},"end":{"line":59,"column":3}},"loc":{"start":{"line":59,"column":22},"end":{"line":64,"column":3}},"line":59},"2":{"name":"(anonymous_2)","decl":{"start":{"line":66,"column":2},"end":{"line":66,"column":3}},"loc":{"start":{"line":66,"column":33},"end":{"line":71,"column":3}},"line":66},"3":{"name":"(anonymous_3)","decl":{"start":{"line":73,"column":33},"end":{"line":73,"column":34}},"loc":{"start":{"line":73,"column":39},"end":{"line":77,"column":3}},"line":73},"4":{"name":"(anonymous_4)","decl":{"start":{"line":79,"column":2},"end":{"line":79,"column":3}},"loc":{"start":{"line":79,"column":11},"end":{"line":88,"column":3}},"line":79}},"branchMap":{"0":{"loc":{"start":{"line":61,"column":4},"end":{"line":63,"column":5}},"type":"if","locations":[{"start":{"line":61,"column":4},"end":{"line":63,"column":5}},{"start":{"line":61,"column":4},"end":{"line":63,"column":5}}],"line":61},"1":{"loc":{"start":{"line":68,"column":4},"end":{"line":70,"column":5}},"type":"if","locations":[{"start":{"line":68,"column":4},"end":{"line":70,"column":5}},{"start":{"line":68,"column":4},"end":{"line":70,"column":5}}],"line":68},"2":{"loc":{"start":{"line":68,"column":8},"end":{"line":68,"column":30}},"type":"binary-expr","locations":[{"start":{"line":68,"column":8},"end":{"line":68,"column":15}},{"start":{"line":68,"column":19},"end":{"line":68,"column":30}}],"line":68}},"s":{"0":6,"1":6,"2":6,"3":6,"4":4,"5":2,"6":2,"7":1,"8":5,"9":5,"10":5,"11":8,"12":8},"f":{"0":6,"1":6,"2":2,"3":5,"4":8},"b":{"0":[4,2],"1":[1,1],"2":[2,2]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"8ecaaaf0d08a532b4b5006f94f10533f6d5682e8"} | ||
} |
@@ -67,2 +67,6 @@ import { createElement, createRef, PureComponent } from 'react'; | ||
if (cursor === document.body && isScrollable(cursor) && !isScrollable(document.documentElement)) { | ||
continue; | ||
} | ||
if (isScrollable(cursor, skipOverflowHiddenElements)) { | ||
@@ -96,11 +100,9 @@ frames.push(cursor); | ||
_width = _frame$getBoundingCli.width, | ||
top = _frame$getBoundingCli.top, | ||
_top = _frame$getBoundingCli.top, | ||
right = _frame$getBoundingCli.right, | ||
bottom = _frame$getBoundingCli.bottom, | ||
left = _frame$getBoundingCli.left; | ||
_left = _frame$getBoundingCli.left; | ||
if (scrollMode === 'if-needed' && targetTop >= 0 && targetRight >= 0) { | ||
if (frame === scrollingElement ? targetBottom <= viewportHeight && targetLeft <= viewportWidth : targetTop >= top && targetBottom <= bottom) { | ||
return computations; | ||
} | ||
if (scrollMode === 'if-needed' && targetTop >= 0 && targetLeft >= 0 && targetBottom <= viewportHeight && targetRight <= viewportWidth && targetTop >= _top && targetBottom <= bottom && targetLeft >= _left && targetRight <= right) { | ||
return computations; | ||
} | ||
@@ -139,23 +141,23 @@ | ||
blockScroll += viewportY; | ||
inlineScroll += viewportX; | ||
blockScroll = Math.max(0, blockScroll + viewportY); | ||
inlineScroll = Math.max(0, inlineScroll + viewportX); | ||
} else { | ||
if (block === 'start') { | ||
blockScroll = targetBlock - top - borderTop; | ||
blockScroll = targetBlock - _top - borderTop; | ||
} else if (block === 'end') { | ||
blockScroll = targetBlock - bottom + borderBottom + scrollbarHeight; | ||
} else if (block === 'nearest') { | ||
blockScroll = alignNearest(top, bottom, _height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight); | ||
blockScroll = alignNearest(_top, bottom, _height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight); | ||
} else { | ||
blockScroll = targetBlock - (top + _height / 2) + scrollbarHeight / 2; | ||
blockScroll = targetBlock - (_top + _height / 2) + scrollbarHeight / 2; | ||
} | ||
if (inline === 'start') { | ||
inlineScroll = targetInline - left - borderLeft; | ||
inlineScroll = targetInline - _left - borderLeft; | ||
} else if (inline === 'center') { | ||
inlineScroll = targetInline - (left + _width / 2) + scrollbarWidth / 2; | ||
inlineScroll = targetInline - (_left + _width / 2) + scrollbarWidth / 2; | ||
} else if (inline === 'end') { | ||
inlineScroll = targetInline - right + borderRight + scrollbarWidth; | ||
} else { | ||
inlineScroll = alignNearest(left, right, _width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth); | ||
inlineScroll = alignNearest(_left, right, _width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth); | ||
} | ||
@@ -162,0 +164,0 @@ |
@@ -72,2 +72,6 @@ (function (global, factory) { | ||
if (cursor === document.body && isScrollable(cursor) && !isScrollable(document.documentElement)) { | ||
continue; | ||
} | ||
if (isScrollable(cursor, skipOverflowHiddenElements)) { | ||
@@ -101,11 +105,9 @@ frames.push(cursor); | ||
_width = _frame$getBoundingCli.width, | ||
top = _frame$getBoundingCli.top, | ||
_top = _frame$getBoundingCli.top, | ||
right = _frame$getBoundingCli.right, | ||
bottom = _frame$getBoundingCli.bottom, | ||
left = _frame$getBoundingCli.left; | ||
_left = _frame$getBoundingCli.left; | ||
if (scrollMode === 'if-needed' && targetTop >= 0 && targetRight >= 0) { | ||
if (frame === scrollingElement ? targetBottom <= viewportHeight && targetLeft <= viewportWidth : targetTop >= top && targetBottom <= bottom) { | ||
return computations; | ||
} | ||
if (scrollMode === 'if-needed' && targetTop >= 0 && targetLeft >= 0 && targetBottom <= viewportHeight && targetRight <= viewportWidth && targetTop >= _top && targetBottom <= bottom && targetLeft >= _left && targetRight <= right) { | ||
return computations; | ||
} | ||
@@ -144,23 +146,23 @@ | ||
blockScroll += viewportY; | ||
inlineScroll += viewportX; | ||
blockScroll = Math.max(0, blockScroll + viewportY); | ||
inlineScroll = Math.max(0, inlineScroll + viewportX); | ||
} else { | ||
if (block === 'start') { | ||
blockScroll = targetBlock - top - borderTop; | ||
blockScroll = targetBlock - _top - borderTop; | ||
} else if (block === 'end') { | ||
blockScroll = targetBlock - bottom + borderBottom + scrollbarHeight; | ||
} else if (block === 'nearest') { | ||
blockScroll = alignNearest(top, bottom, _height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight); | ||
blockScroll = alignNearest(_top, bottom, _height, borderTop, borderBottom + scrollbarHeight, targetBlock, targetBlock + targetHeight, targetHeight); | ||
} else { | ||
blockScroll = targetBlock - (top + _height / 2) + scrollbarHeight / 2; | ||
blockScroll = targetBlock - (_top + _height / 2) + scrollbarHeight / 2; | ||
} | ||
if (inline === 'start') { | ||
inlineScroll = targetInline - left - borderLeft; | ||
inlineScroll = targetInline - _left - borderLeft; | ||
} else if (inline === 'center') { | ||
inlineScroll = targetInline - (left + _width / 2) + scrollbarWidth / 2; | ||
inlineScroll = targetInline - (_left + _width / 2) + scrollbarWidth / 2; | ||
} else if (inline === 'end') { | ||
inlineScroll = targetInline - right + borderRight + scrollbarWidth; | ||
} else { | ||
inlineScroll = alignNearest(left, right, _width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth); | ||
inlineScroll = alignNearest(_left, right, _width, borderLeft, borderRight + scrollbarWidth, targetInline, targetInline + targetWidth, targetWidth); | ||
} | ||
@@ -167,0 +169,0 @@ |
{ | ||
"name": "react-scroll-into-view-if-needed", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "A thin component wrapper around scroll-into-view-if-needed", | ||
@@ -47,3 +47,3 @@ "main": "dist/umd/index.js", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"scroll-into-view-if-needed": "^2.2.11" | ||
"scroll-into-view-if-needed": "^2.2.16" | ||
}, | ||
@@ -50,0 +50,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
704003
43
1627