|
1 | 1 | /** |
2 | 2 | * @fileOverview Kickass library to create and place poppers near their reference elements. |
3 | | - * @version 0.2.2 |
| 3 | + * @version 0.2.4 |
4 | 4 | * @license |
5 | 5 | * Copyright (c) 2016 Federico Zivolo and contributors |
6 | 6 | * |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 |
|
| 187 | + Popper.prototype.state = {}; |
| 188 | + |
187 | 189 | // |
188 | 190 | // Methods |
189 | 191 | // |
|
364 | 366 | // If the trigger is inside a fixed context, the popper will be fixed as well to allow them to scroll together |
365 | 367 | var isParentFixed = isFixed(trigger, container); |
366 | 368 | popperOffsets.position = isParentFixed ? 'fixed' : 'absolute'; |
| 369 | + this.state.position = popperOffsets.position; |
367 | 370 |
|
368 | 371 |
|
369 | 372 | // |
|
420 | 423 | // NOTE: 1 DOM access here |
421 | 424 | _updateBound = this.update.bind(this); |
422 | 425 | 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') { |
424 | 428 | var target = getScrollParent(this._trigger); |
425 | 429 | // here it could be both `body` or `documentElement` thanks to Firefox, we then check both |
426 | 430 | if (target === root.document.body || target === root.document.documentElement) { |
|
439 | 443 | Popper.prototype._removeEventListeners = function() { |
440 | 444 | // NOTE: 1 DOM access here |
441 | 445 | root.removeEventListener('resize', _updateBound); |
442 | | - if (this._options.boundariesElement !== 'window') { |
| 446 | + if (this._options.boundariesElement !== 'window' && this.state.position !== 'fixed') { |
443 | 447 | var target = getScrollParent(this._trigger); |
444 | 448 | // here it could be both `body` or `documentElement` thanks to Firefox, we then check both |
445 | 449 | if (target === root.document.body || target === root.document.documentElement) { |
|
0 commit comments