motion-v
Version:
<p align="center"> <img width="100" height="100" alt="Motion logo" src="https://user-images.githubusercontent.com/7850794/164965523-3eced4c4-6020-467e-acde-f11b7900ad62.png" /> </p> <h1 align="center">Motion for Vue</h1>
62 lines (61 loc) • 2.11 kB
JavaScript
import { Feature } from "../feature.mjs";
import { addScaleCorrector } from "../../external/.pnpm/framer-motion@12.23.12/external/framer-motion/dist/es/projection/styles/scale-correction.mjs";
import { defaultScaleCorrector } from "./config.mjs";
import { globalProjectionState } from "../../external/.pnpm/framer-motion@12.23.12/external/framer-motion/dist/es/projection/node/state.mjs";
class LayoutFeature extends Feature {
constructor(state) {
super(state);
addScaleCorrector(defaultScaleCorrector);
}
beforeUpdate() {
this.state.willUpdate("beforeUpdate");
}
update() {
this.didUpdate();
}
didUpdate() {
var _a, _b;
if (this.state.options.layout || this.state.options.layoutId || this.state.options.drag) {
(_b = (_a = this.state.visualElement.projection) == null ? void 0 : _a.root) == null ? void 0 : _b.didUpdate();
}
}
mount() {
var _a;
const options = this.state.options;
const layoutGroup = this.state.options.layoutGroup;
if (options.layout || options.layoutId) {
const projection = this.state.visualElement.projection;
if (projection) {
projection.promote();
(_a = layoutGroup == null ? void 0 : layoutGroup.group) == null ? void 0 : _a.add(projection);
}
globalProjectionState.hasEverUpdated = true;
}
this.didUpdate();
}
beforeUnmount() {
const projection = this.state.visualElement.projection;
if (projection) {
this.state.willUpdate("beforeUnmount");
if (this.state.options.layoutId) {
projection.isPresent = false;
projection.relegate();
} else if (this.state.options.layout) {
this.state.isSafeToRemove = true;
}
}
}
unmount() {
const layoutGroup = this.state.options.layoutGroup;
const projection = this.state.visualElement.projection;
if (projection) {
if ((layoutGroup == null ? void 0 : layoutGroup.group) && (this.state.options.layout || this.state.options.layoutId)) {
layoutGroup.group.remove(projection);
}
this.didUpdate();
}
}
}
export {
LayoutFeature
};