MCPcopy
hub / github.com/formkit/auto-animate / updatePos

Function updatePos

src/index.ts:184–207  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 */
184function 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.

Callers 3

handleResizesFunction · 0.85
observePositionFunction · 0.85
updateAllPosFunction · 0.85

Calls 4

getOptionsFunction · 0.85
isPluginFunction · 0.85
getCoordsFunction · 0.85
observePositionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…