Skip to content

Commit

Permalink
fixed fixed poppers on Safari Mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
FezVrasta committed Apr 6, 2016
1 parent 7a0ae40 commit 35bbbc6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/popper.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
}
}

Popper.prototype.state = {};

//
// Methods
//
Expand Down Expand Up @@ -364,6 +366,7 @@
// If the trigger is inside a fixed context, the popper will be fixed as well to allow them to scroll together
var isParentFixed = isFixed(trigger, container);
popperOffsets.position = isParentFixed ? 'fixed' : 'absolute';
this.state.position = popperOffsets.position;


//
Expand Down Expand Up @@ -420,7 +423,8 @@
// NOTE: 1 DOM access here
_updateBound = this.update.bind(this);
root.addEventListener('resize', _updateBound);
if (this._options.boundariesElement !== 'window') {
// if the boundariesElement is window or the popper position is fixed, we don't need to listen for the scroll event
if (this._options.boundariesElement !== 'window' && this.state.position !== 'fixed') {
var target = getScrollParent(this._trigger);
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
if (target === root.document.body || target === root.document.documentElement) {
Expand All @@ -439,7 +443,7 @@
Popper.prototype._removeEventListeners = function() {
// NOTE: 1 DOM access here
root.removeEventListener('resize', _updateBound);
if (this._options.boundariesElement !== 'window') {
if (this._options.boundariesElement !== 'window' && this.state.position !== 'fixed') {
var target = getScrollParent(this._trigger);
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
if (target === root.document.body || target === root.document.documentElement) {
Expand Down

0 comments on commit 35bbbc6

Please sign in to comment.