till download files, everything works
This commit is contained in:
1 parent
ce893a4185
commit
ed1a580b09
6050 files changed
+768543
-177
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
|
||||
import { SVGVisualElement } from '../../render/svg/SVGVisualElement.mjs';
|
||||
import { HTMLVisualElement } from '../../render/html/HTMLVisualElement.mjs';
|
||||
import { visualElementStore } from '../../render/store.mjs';
|
||||
import { ObjectVisualElement } from '../../render/object/ObjectVisualElement.mjs';
|
||||
|
||||
function createDOMVisualElement(element) {
|
||||
const options = {
|
||||
presenceContext: null,
|
||||
props: {},
|
||||
visualState: {
|
||||
renderState: {
|
||||
transform: {},
|
||||
transformOrigin: {},
|
||||
style: {},
|
||||
vars: {},
|
||||
attrs: {},
|
||||
},
|
||||
latestValues: {},
|
||||
},
|
||||
};
|
||||
const node = isSVGElement(element)
|
||||
? new SVGVisualElement(options)
|
||||
: new HTMLVisualElement(options);
|
||||
node.mount(element);
|
||||
visualElementStore.set(element, node);
|
||||
}
|
||||
function createObjectVisualElement(subject) {
|
||||
const options = {
|
||||
presenceContext: null,
|
||||
props: {},
|
||||
visualState: {
|
||||
renderState: {
|
||||
output: {},
|
||||
},
|
||||
latestValues: {},
|
||||
},
|
||||
};
|
||||
const node = new ObjectVisualElement(options);
|
||||
node.mount(subject);
|
||||
visualElementStore.set(subject, node);
|
||||
}
|
||||
|
||||
export { createDOMVisualElement, createObjectVisualElement };
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { transformProps } from '../../render/html/utils/transform.mjs';
|
||||
|
||||
const underDampedSpring = {
|
||||
type: "spring",
|
||||
stiffness: 500,
|
||||
damping: 25,
|
||||
restSpeed: 10,
|
||||
};
|
||||
const criticallyDampedSpring = (target) => ({
|
||||
type: "spring",
|
||||
stiffness: 550,
|
||||
damping: target === 0 ? 2 * Math.sqrt(550) : 30,
|
||||
restSpeed: 10,
|
||||
});
|
||||
const keyframesTransition = {
|
||||
type: "keyframes",
|
||||
duration: 0.8,
|
||||
};
|
||||
/**
|
||||
* Default easing curve is a slightly shallower version of
|
||||
* the default browser easing curve.
|
||||
*/
|
||||
const ease = {
|
||||
type: "keyframes",
|
||||
ease: [0.25, 0.1, 0.35, 1],
|
||||
duration: 0.3,
|
||||
};
|
||||
const getDefaultTransition = (valueKey, { keyframes }) => {
|
||||
if (keyframes.length > 2) {
|
||||
return keyframesTransition;
|
||||
}
|
||||
else if (transformProps.has(valueKey)) {
|
||||
return valueKey.startsWith("scale")
|
||||
? criticallyDampedSpring(keyframes[1])
|
||||
: underDampedSpring;
|
||||
}
|
||||
return ease;
|
||||
};
|
||||
|
||||
export { getDefaultTransition };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function getValueTransition(transition, key) {
|
||||
return transition
|
||||
? transition[key] ||
|
||||
transition["default"] ||
|
||||
transition
|
||||
: undefined;
|
||||
}
|
||||
|
||||
export { getValueTransition };
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import { complex } from '../../value/types/complex/index.mjs';
|
||||
|
||||
/**
|
||||
* Check if a value is animatable. Examples:
|
||||
*
|
||||
* ✅: 100, "100px", "#fff"
|
||||
* ❌: "block", "url(2.jpg)"
|
||||
* @param value
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const isAnimatable = (value, name) => {
|
||||
// If the list of keys tat might be non-animatable grows, replace with Set
|
||||
if (name === "zIndex")
|
||||
return false;
|
||||
// If it's a number or a keyframes array, we can animate it. We might at some point
|
||||
// need to do a deep isAnimatable check of keyframes, or let Popmotion handle this,
|
||||
// but for now lets leave it like this for performance reasons
|
||||
if (typeof value === "number" || Array.isArray(value))
|
||||
return true;
|
||||
if (typeof value === "string" && // It's animatable if we have a string
|
||||
(complex.test(value) || value === "0") && // And it contains numbers and/or colors
|
||||
!value.startsWith("url(") // Unless it starts with "url("
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
export { isAnimatable };
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
function isAnimationControls(v) {
|
||||
return (v !== null &&
|
||||
typeof v === "object" &&
|
||||
typeof v.start === "function");
|
||||
}
|
||||
|
||||
export { isAnimationControls };
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
function isDOMKeyframes(keyframes) {
|
||||
return typeof keyframes === "object" && !Array.isArray(keyframes);
|
||||
}
|
||||
|
||||
export { isDOMKeyframes };
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
const isKeyframesTarget = (v) => {
|
||||
return Array.isArray(v);
|
||||
};
|
||||
|
||||
export { isKeyframesTarget };
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { isZeroValueString } from '../../utils/is-zero-value-string.mjs';
|
||||
|
||||
function isNone(value) {
|
||||
if (typeof value === "number") {
|
||||
return value === 0;
|
||||
}
|
||||
else if (value !== null) {
|
||||
return value === "none" || value === "0" || isZeroValueString(value);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export { isNone };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Decide whether a transition is defined on a given Transition.
|
||||
* This filters out orchestration options and returns true
|
||||
* if any options are left.
|
||||
*/
|
||||
function isTransitionDefined({ when, delay: _delay, delayChildren, staggerChildren, staggerDirection, repeat, repeatType, repeatDelay, from, elapsed, ...transition }) {
|
||||
return !!Object.keys(transition).length;
|
||||
}
|
||||
|
||||
export { isTransitionDefined };
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { easingDefinitionToFunction } from '../../easing/utils/map.mjs';
|
||||
|
||||
function getOriginIndex(from, total) {
|
||||
if (from === "first") {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
const lastIndex = total - 1;
|
||||
return from === "last" ? lastIndex : lastIndex / 2;
|
||||
}
|
||||
}
|
||||
function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
|
||||
return (i, total) => {
|
||||
const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
|
||||
const distance = Math.abs(fromIndex - i);
|
||||
let delay = duration * distance;
|
||||
if (ease) {
|
||||
const maxDelay = total * duration;
|
||||
const easingFunction = easingDefinitionToFunction(ease);
|
||||
delay = easingFunction(delay / maxDelay) * maxDelay;
|
||||
}
|
||||
return startDelay + delay;
|
||||
};
|
||||
}
|
||||
|
||||
export { getOriginIndex, stagger };
|
||||
Reference in new issue
Block a user