171 lines
5.4 KiB
JavaScript
171 lines
5.4 KiB
JavaScript
import {
|
|
cubicInOut,
|
|
cubicOut
|
|
} from "./chunk-ACBGUER4.js";
|
|
import {
|
|
assign,
|
|
identity,
|
|
is_function
|
|
} from "./chunk-RILKTLQD.js";
|
|
|
|
// node_modules/.pnpm/svelte@3.55.0/node_modules/svelte/transition/index.mjs
|
|
function __rest(s, e) {
|
|
var t = {};
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
t[p] = s[p];
|
|
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
t[p[i]] = s[p[i]];
|
|
}
|
|
return t;
|
|
}
|
|
function blur(node, { delay = 0, duration = 400, easing = cubicInOut, amount = 5, opacity = 0 } = {}) {
|
|
const style = getComputedStyle(node);
|
|
const target_opacity = +style.opacity;
|
|
const f = style.filter === "none" ? "" : style.filter;
|
|
const od = target_opacity * (1 - opacity);
|
|
return {
|
|
delay,
|
|
duration,
|
|
easing,
|
|
css: (_t, u) => `opacity: ${target_opacity - od * u}; filter: ${f} blur(${u * amount}px);`
|
|
};
|
|
}
|
|
function fade(node, { delay = 0, duration = 400, easing = identity } = {}) {
|
|
const o = +getComputedStyle(node).opacity;
|
|
return {
|
|
delay,
|
|
duration,
|
|
easing,
|
|
css: (t) => `opacity: ${t * o}`
|
|
};
|
|
}
|
|
function fly(node, { delay = 0, duration = 400, easing = cubicOut, x = 0, y = 0, opacity = 0 } = {}) {
|
|
const style = getComputedStyle(node);
|
|
const target_opacity = +style.opacity;
|
|
const transform = style.transform === "none" ? "" : style.transform;
|
|
const od = target_opacity * (1 - opacity);
|
|
return {
|
|
delay,
|
|
duration,
|
|
easing,
|
|
css: (t, u) => `
|
|
transform: ${transform} translate(${(1 - t) * x}px, ${(1 - t) * y}px);
|
|
opacity: ${target_opacity - od * u}`
|
|
};
|
|
}
|
|
function slide(node, { delay = 0, duration = 400, easing = cubicOut } = {}) {
|
|
const style = getComputedStyle(node);
|
|
const opacity = +style.opacity;
|
|
const height = parseFloat(style.height);
|
|
const padding_top = parseFloat(style.paddingTop);
|
|
const padding_bottom = parseFloat(style.paddingBottom);
|
|
const margin_top = parseFloat(style.marginTop);
|
|
const margin_bottom = parseFloat(style.marginBottom);
|
|
const border_top_width = parseFloat(style.borderTopWidth);
|
|
const border_bottom_width = parseFloat(style.borderBottomWidth);
|
|
return {
|
|
delay,
|
|
duration,
|
|
easing,
|
|
css: (t) => `overflow: hidden;opacity: ${Math.min(t * 20, 1) * opacity};height: ${t * height}px;padding-top: ${t * padding_top}px;padding-bottom: ${t * padding_bottom}px;margin-top: ${t * margin_top}px;margin-bottom: ${t * margin_bottom}px;border-top-width: ${t * border_top_width}px;border-bottom-width: ${t * border_bottom_width}px;`
|
|
};
|
|
}
|
|
function scale(node, { delay = 0, duration = 400, easing = cubicOut, start = 0, opacity = 0 } = {}) {
|
|
const style = getComputedStyle(node);
|
|
const target_opacity = +style.opacity;
|
|
const transform = style.transform === "none" ? "" : style.transform;
|
|
const sd = 1 - start;
|
|
const od = target_opacity * (1 - opacity);
|
|
return {
|
|
delay,
|
|
duration,
|
|
easing,
|
|
css: (_t, u) => `
|
|
transform: ${transform} scale(${1 - sd * u});
|
|
opacity: ${target_opacity - od * u}
|
|
`
|
|
};
|
|
}
|
|
function draw(node, { delay = 0, speed, duration, easing = cubicInOut } = {}) {
|
|
let len = node.getTotalLength();
|
|
const style = getComputedStyle(node);
|
|
if (style.strokeLinecap !== "butt") {
|
|
len += parseInt(style.strokeWidth);
|
|
}
|
|
if (duration === void 0) {
|
|
if (speed === void 0) {
|
|
duration = 800;
|
|
} else {
|
|
duration = len / speed;
|
|
}
|
|
} else if (typeof duration === "function") {
|
|
duration = duration(len);
|
|
}
|
|
return {
|
|
delay,
|
|
duration,
|
|
easing,
|
|
css: (t, u) => `stroke-dasharray: ${t * len} ${u * len}`
|
|
};
|
|
}
|
|
function crossfade(_a) {
|
|
var { fallback } = _a, defaults = __rest(_a, ["fallback"]);
|
|
const to_receive = /* @__PURE__ */ new Map();
|
|
const to_send = /* @__PURE__ */ new Map();
|
|
function crossfade2(from, node, params) {
|
|
const { delay = 0, duration = (d2) => Math.sqrt(d2) * 30, easing = cubicOut } = assign(assign({}, defaults), params);
|
|
const to = node.getBoundingClientRect();
|
|
const dx = from.left - to.left;
|
|
const dy = from.top - to.top;
|
|
const dw = from.width / to.width;
|
|
const dh = from.height / to.height;
|
|
const d = Math.sqrt(dx * dx + dy * dy);
|
|
const style = getComputedStyle(node);
|
|
const transform = style.transform === "none" ? "" : style.transform;
|
|
const opacity = +style.opacity;
|
|
return {
|
|
delay,
|
|
duration: is_function(duration) ? duration(d) : duration,
|
|
easing,
|
|
css: (t, u) => `
|
|
opacity: ${t * opacity};
|
|
transform-origin: top left;
|
|
transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1 - t) * dw}, ${t + (1 - t) * dh});
|
|
`
|
|
};
|
|
}
|
|
function transition(items, counterparts, intro) {
|
|
return (node, params) => {
|
|
items.set(params.key, {
|
|
rect: node.getBoundingClientRect()
|
|
});
|
|
return () => {
|
|
if (counterparts.has(params.key)) {
|
|
const { rect } = counterparts.get(params.key);
|
|
counterparts.delete(params.key);
|
|
return crossfade2(rect, node, params);
|
|
}
|
|
items.delete(params.key);
|
|
return fallback && fallback(node, params, intro);
|
|
};
|
|
};
|
|
}
|
|
return [
|
|
transition(to_send, to_receive, false),
|
|
transition(to_receive, to_send, true)
|
|
];
|
|
}
|
|
export {
|
|
blur,
|
|
crossfade,
|
|
draw,
|
|
fade,
|
|
fly,
|
|
scale,
|
|
slide
|
|
};
|
|
//# sourceMappingURL=svelte_transition.js.map
|