first commit
This commit is contained in:
36
node_modules/framer-motion/dist/es/motion/features/animation/exit.mjs
generated
vendored
Normal file
36
node_modules/framer-motion/dist/es/motion/features/animation/exit.mjs
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Feature } from '../Feature.mjs';
|
||||
|
||||
let id = 0;
|
||||
class ExitAnimationFeature extends Feature {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.id = id++;
|
||||
}
|
||||
update() {
|
||||
if (!this.node.presenceContext)
|
||||
return;
|
||||
const { isPresent, onExitComplete } = this.node.presenceContext;
|
||||
const { isPresent: prevIsPresent } = this.node.prevPresenceContext || {};
|
||||
if (!this.node.animationState || isPresent === prevIsPresent) {
|
||||
return;
|
||||
}
|
||||
const exitAnimation = this.node.animationState.setActive("exit", !isPresent);
|
||||
if (onExitComplete && !isPresent) {
|
||||
exitAnimation.then(() => {
|
||||
onExitComplete(this.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
mount() {
|
||||
const { register, onExitComplete } = this.node.presenceContext || {};
|
||||
if (onExitComplete) {
|
||||
onExitComplete(this.id);
|
||||
}
|
||||
if (register) {
|
||||
this.unmount = register(this.id);
|
||||
}
|
||||
}
|
||||
unmount() { }
|
||||
}
|
||||
|
||||
export { ExitAnimationFeature };
|
||||
Reference in New Issue
Block a user