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

Function deletePosition

src/index.ts:807–835  ·  view source on GitHub ↗

* Determines the position of the element being removed. * @param el - The element being deleted * @returns

(
  el: Element,
)

Source from the content-addressed store, hash-verified

805 * @returns
806 */
807function deletePosition(
808 el: Element,
809): [top: number, left: number, width: number, height: number] {
810 const oldCoords = coords.get(el)!
811 const [width, , height] = getTransitionSizes(el, oldCoords, getCoords(el))
812
813 let offsetParent: Element | null = (el as HTMLElement).parentElement
814 while (
815 offsetParent &&
816 (getComputedStyle(offsetParent).position === "static" ||
817 offsetParent instanceof HTMLBodyElement)
818 ) {
819 offsetParent = (offsetParent as HTMLElement).parentElement
820 }
821 if (!offsetParent) offsetParent = document.body
822 const parentStyles = getComputedStyle(offsetParent)
823 const parentCoords =
824 !animations.has(el) || animations.get(el)?.playState === "finished"
825 ? getCoords(offsetParent)
826 : coords.get(offsetParent)!
827
828 const top =
829 Math.round(oldCoords.top - parentCoords.top) -
830 raw(parentStyles.borderTopWidth)
831 const left =
832 Math.round(oldCoords.left - parentCoords.left) -
833 raw(parentStyles.borderLeftWidth)
834 return [top, left, width, height]
835}
836
837export interface AutoAnimateOptions {
838 /**

Callers 1

removeFunction · 0.85

Calls 3

getTransitionSizesFunction · 0.85
getCoordsFunction · 0.85
rawFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…