Skip to content

Commit c029f5a

Browse files
committed
Changed logic so that _scrollToTopIfVisible is called only if element is in viewport. Previously it was called only when the element was outside it. Also changed the logic of _isElementOutOfViewport to work correctly.
1 parent c7c66ad commit c029f5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/web/mage/collapsible.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ define([
570570
* @private
571571
*/
572572
_scrollToTopIfVisible: function (elem) {
573-
if (this._isElementOutOfViewport(elem)) {
573+
if (!this._isElementOutOfViewport(elem)) {
574574
elem.scrollIntoView();
575575
}
576576
},
@@ -583,7 +583,7 @@ define([
583583
_isElementOutOfViewport: function (elem) {
584584
var rect = elem.getBoundingClientRect();
585585

586-
return rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight;
586+
return rect.bottom > window.innerHeight || rect.right < 0 || rect.left > window.innerWidth || rect.top < 0;
587587
}
588588
});
589589

0 commit comments

Comments
 (0)