* 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
()
| 2415 | * @memberof Popper |
| 2416 | */ |
| 2417 | function update() { |
| 2418 | // if popper is destroyed, don't perform any further update |
| 2419 | if (this.state.isDestroyed) { |
| 2420 | return; |
| 2421 | } |
| 2422 | |
| 2423 | var data = { |
| 2424 | instance: this, |
| 2425 | styles: {}, |
| 2426 | arrowStyles: {}, |
| 2427 | attributes: {}, |
| 2428 | flipped: false, |
| 2429 | offsets: {} |
| 2430 | }; |
| 2431 | |
| 2432 | // compute reference element offsets |
| 2433 | data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); |
| 2434 | |
| 2435 | // compute auto placement, store placement inside the data object, |
| 2436 | // modifiers will be able to edit `placement` if needed |
| 2437 | // and refer to originalPlacement to know the original value |
| 2438 | data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); |
| 2439 | |
| 2440 | // store the computed placement inside `originalPlacement` |
| 2441 | data.originalPlacement = data.placement; |
| 2442 | |
| 2443 | data.positionFixed = this.options.positionFixed; |
| 2444 | |
| 2445 | // compute the popper offsets |
| 2446 | data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement); |
| 2447 | |
| 2448 | data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute'; |
| 2449 | |
| 2450 | // run the modifiers |
| 2451 | data = runModifiers(this.modifiers, data); |
| 2452 | |
| 2453 | // the first `update` will call `onCreate` callback |
| 2454 | // the other ones will call `onUpdate` callback |
| 2455 | if (!this.state.isCreated) { |
| 2456 | this.state.isCreated = true; |
| 2457 | this.options.onCreate(data); |
| 2458 | } else { |
| 2459 | this.options.onUpdate(data); |
| 2460 | } |
| 2461 | } |
| 2462 | |
| 2463 | /** |
| 2464 | * Helper used to know if the given modifier is enabled. |
nothing calls this directly
no test coverage detected