Skip to content

Commit

Permalink
Merge pull request #2999 from magento-honey-badgers/MAGETWO-91504-pdp…
Browse files Browse the repository at this point in the history
…-mobile

[honey] MAGETWO-91504: Mobile PDP accordion widget hides accordion content on phones with iOS
  • Loading branch information
cpartica authored Aug 14, 2018
2 parents 11ade1f + 4f6b8a2 commit 8c1bd4c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/web/mage/collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ define([
if (this.options.animate) {
this._animate(showProps);
} else {
this._scrollToTopIfVisible(this.content.get(0).parentElement);
this.content.show();
}
this._open();
Expand Down Expand Up @@ -553,6 +554,27 @@ define([
}, 1);
});
}
},

/**
* @param {HTMLElement} elem
* @private
*/
_scrollToTopIfVisible: function (elem) {
if (this._isElementOutOfViewport(elem)) {
elem.scrollIntoView();
}
},

/**
* @param {HTMLElement} elem
* @private
* @return {Boolean}
*/
_isElementOutOfViewport: function (elem) {
var rect = elem.getBoundingClientRect();

return rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight;
}
});

Expand Down

0 comments on commit 8c1bd4c

Please sign in to comment.