* Updates the position of the popper, computing the new offsets and applying * the new style. * Prefer `scheduleUpdate` over `update` because of performance reasons. * @method * @memberof Popper
()
| 3883 | |
| 3884 | |
| 3885 | function update() { |
| 3886 | // if popper is destroyed, don't perform any further update |
| 3887 | if (this.state.isDestroyed) { |
| 3888 | return; |
| 3889 | } |
| 3890 | |
| 3891 | var data = { |
| 3892 | instance: this, |
| 3893 | styles: {}, |
| 3894 | arrowStyles: {}, |
| 3895 | attributes: {}, |
| 3896 | flipped: false, |
| 3897 | offsets: {} |
| 3898 | }; // compute reference element offsets |
| 3899 | |
| 3900 | data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); // compute auto placement, store placement inside the data object, |
| 3901 | // modifiers will be able to edit `placement` if needed |
| 3902 | // and refer to originalPlacement to know the original value |
| 3903 | |
| 3904 | data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); // store the computed placement inside `originalPlacement` |
| 3905 | |
| 3906 | data.originalPlacement = data.placement; |
| 3907 | data.positionFixed = this.options.positionFixed; // compute the popper offsets |
| 3908 | |
| 3909 | data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement); |
| 3910 | data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute'; // run the modifiers |
| 3911 | |
| 3912 | data = runModifiers(this.modifiers, data); // the first `update` will call `onCreate` callback |
| 3913 | // the other ones will call `onUpdate` callback |
| 3914 | |
| 3915 | if (!this.state.isCreated) { |
| 3916 | this.state.isCreated = true; |
| 3917 | this.options.onCreate(data); |
| 3918 | } else { |
| 3919 | this.options.onUpdate(data); |
| 3920 | } |
| 3921 | } |
| 3922 | /** |
| 3923 | * Helper used to know if the given modifier is enabled. |
| 3924 | * @method |
nothing calls this directly
no test coverage detected
searching dependent graphs…