Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 8c1bd4c

Browse files
authored
Merge pull request #2999 from magento-honey-badgers/MAGETWO-91504-pdp-mobile
[honey] MAGETWO-91504: Mobile PDP accordion widget hides accordion content on phones with iOS
2 parents 11ade1f + 4f6b8a2 commit 8c1bd4c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/web/mage/collapsible.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ define([
448448
if (this.options.animate) {
449449
this._animate(showProps);
450450
} else {
451+
this._scrollToTopIfVisible(this.content.get(0).parentElement);
451452
this.content.show();
452453
}
453454
this._open();
@@ -553,6 +554,27 @@ define([
553554
}, 1);
554555
});
555556
}
557+
},
558+
559+
/**
560+
* @param {HTMLElement} elem
561+
* @private
562+
*/
563+
_scrollToTopIfVisible: function (elem) {
564+
if (this._isElementOutOfViewport(elem)) {
565+
elem.scrollIntoView();
566+
}
567+
},
568+
569+
/**
570+
* @param {HTMLElement} elem
571+
* @private
572+
* @return {Boolean}
573+
*/
574+
_isElementOutOfViewport: function (elem) {
575+
var rect = elem.getBoundingClientRect();
576+
577+
return rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight;
556578
}
557579
});
558580

0 commit comments

Comments
 (0)