* Update the exact position of a given element. * @param el - An element to update the position of. * @param debounce - Whether or not to debounce the update. After an animation is finished, it should update as soon as possible to prevent flickering on quick toggles.
(el: Element, debounce = true)
| 182 | * @param debounce - Whether or not to debounce the update. After an animation is finished, it should update as soon as possible to prevent flickering on quick toggles. |
| 183 | */ |
| 184 | function updatePos(el: Element, debounce = true) { |
| 185 | clearTimeout(debounces.get(el)) |
| 186 | const optionsOrPlugin = getOptions(el) |
| 187 | const delay = debounce |
| 188 | ? isPlugin(optionsOrPlugin) |
| 189 | ? 500 |
| 190 | : optionsOrPlugin.duration |
| 191 | : 0 |
| 192 | debounces.set( |
| 193 | el, |
| 194 | setTimeout(async () => { |
| 195 | const currentAnimation = animations.get(el) |
| 196 | |
| 197 | try { |
| 198 | await currentAnimation?.finished |
| 199 | |
| 200 | coords.set(el, getCoords(el)) |
| 201 | observePosition(el) |
| 202 | } catch { |
| 203 | // ignore errors as the `.finished` promise is rejected when animations were cancelled |
| 204 | } |
| 205 | }, delay), |
| 206 | ) |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Updates all positions that are currently being tracked. |
no test coverage detected
searching dependent graphs…