Skip to content

Commit 684f78e

Browse files
committed
MAGETWO-91504: Mobile PDP accordion widget hides accordion content on phones with iOS
- only scroll to element when element gets out of the viewport
1 parent 3d26304 commit 684f78e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/web/mage/collapsible.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ define([
448448
if (this.options.animate) {
449449
this._animate(showProps);
450450
} else {
451-
this.content.get(0).parentElement.scrollIntoView();
451+
if (this._isElementOutOfViewport(this.content.get(0).parentElement)) {
452+
this.content.get(0).parentElement.scrollIntoView();
453+
}
452454
this.content.show();
453455
}
454456
this._open();
@@ -554,6 +556,14 @@ define([
554556
}, 1);
555557
});
556558
}
559+
},
560+
561+
/**
562+
* @private
563+
*/
564+
_isElementOutOfViewport: function (el) {
565+
var rect = el.getBoundingClientRect();
566+
return rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight;
557567
}
558568
});
559569

0 commit comments

Comments
 (0)