Destroys the given element or selector.
All registered destructors are called. The element is then removed from the DOM.
Unfinished requests targeting the destroyed fragment or its descendants are aborted.
Emits events up:fragment:destroyed
.
You may animate the element's removal by passing an option like { animate: 'fade-out' }
.
Unpoly ships with a number of predefined animations and
you may so define custom animations.
If the element's removal is animated, the element will remain in the DOM until after the animation
has completed. While the animation is running the element will be given the .up-destroying
class.
The element will also be given the [aria-hidden]
attribute to remove it from
the accessibility tree.
Elements that are about to be destroyed (but still animating) are ignored by all
functions that lookup fragments, like up.fragment.all()
, up.fragment.get()
or up.fragment.closest()
.
If a destructor throws an error, up.destroy()
will still remove the element and not throw an error.
Instead compiler errors will print to the error console
and emit an error
event on window
.
See errors in user code for details.
The animation to use before the element is removed from the DOM.
The duration of the animation. See up.animate()
.
The timing function that controls the animation's acceleration. See up.animate()
.
A callback that is run when any animations are finished and the element was removed from the DOM.
undefined