Skip to content

Commit 35bbbc6

Browse files
committed
fixed fixed poppers on Safari Mobile
1 parent 7a0ae40 commit 35bbbc6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/popper.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@
184184
}
185185
}
186186

187+
Popper.prototype.state = {};
188+
187189
//
188190
// Methods
189191
//
@@ -364,6 +366,7 @@
364366
// If the trigger is inside a fixed context, the popper will be fixed as well to allow them to scroll together
365367
var isParentFixed = isFixed(trigger, container);
366368
popperOffsets.position = isParentFixed ? 'fixed' : 'absolute';
369+
this.state.position = popperOffsets.position;
367370

368371

369372
//
@@ -420,7 +423,8 @@
420423
// NOTE: 1 DOM access here
421424
_updateBound = this.update.bind(this);
422425
root.addEventListener('resize', _updateBound);
423-
if (this._options.boundariesElement !== 'window') {
426+
// if the boundariesElement is window or the popper position is fixed, we don't need to listen for the scroll event
427+
if (this._options.boundariesElement !== 'window' && this.state.position !== 'fixed') {
424428
var target = getScrollParent(this._trigger);
425429
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
426430
if (target === root.document.body || target === root.document.documentElement) {
@@ -439,7 +443,7 @@
439443
Popper.prototype._removeEventListeners = function() {
440444
// NOTE: 1 DOM access here
441445
root.removeEventListener('resize', _updateBound);
442-
if (this._options.boundariesElement !== 'window') {
446+
if (this._options.boundariesElement !== 'window' && this.state.position !== 'fixed') {
443447
var target = getScrollParent(this._trigger);
444448
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
445449
if (target === root.document.body || target === root.document.documentElement) {

0 commit comments

Comments
 (0)