@teleporthq/teleport-shared 0.43.70 → 0.43.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/function-sources.ts +30 -0
- package/__tests__/motion-runtime/motion-engine.ts +102 -0
- package/__tests__/motion-runtime/scroll-video-engine.ts +28 -0
- package/__tests__/scroll-scene/story-lanes.ts +126 -0
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/motion-runtime/index.d.ts +3 -0
- package/dist/cjs/motion-runtime/index.d.ts.map +1 -0
- package/dist/cjs/motion-runtime/index.js +8 -0
- package/dist/cjs/motion-runtime/index.js.map +1 -0
- package/dist/cjs/motion-runtime/motion-engine-source.d.ts +16 -0
- package/dist/cjs/motion-runtime/motion-engine-source.d.ts.map +1 -0
- package/dist/cjs/motion-runtime/motion-engine-source.js +20 -0
- package/dist/cjs/motion-runtime/motion-engine-source.js.map +1 -0
- package/dist/cjs/motion-runtime/scroll-video-engine-source.d.ts +9 -0
- package/dist/cjs/motion-runtime/scroll-video-engine-source.d.ts.map +1 -0
- package/dist/cjs/motion-runtime/scroll-video-engine-source.js +13 -0
- package/dist/cjs/motion-runtime/scroll-video-engine-source.js.map +1 -0
- package/dist/cjs/page-transition/index.d.ts +5 -0
- package/dist/cjs/page-transition/index.d.ts.map +1 -0
- package/dist/cjs/page-transition/index.js +21 -0
- package/dist/cjs/page-transition/index.js.map +1 -0
- package/dist/cjs/page-transition/morph-source.d.ts +20 -0
- package/dist/cjs/page-transition/morph-source.d.ts.map +1 -0
- package/dist/cjs/page-transition/morph-source.js +25 -0
- package/dist/cjs/page-transition/morph-source.js.map +1 -0
- package/dist/cjs/page-transition/variant-sources.generated.d.ts +7 -0
- package/dist/cjs/page-transition/variant-sources.generated.d.ts.map +1 -0
- package/dist/cjs/page-transition/variant-sources.generated.js +14 -0
- package/dist/cjs/page-transition/variant-sources.generated.js.map +1 -0
- package/dist/cjs/page-transition/variants.d.ts +87 -0
- package/dist/cjs/page-transition/variants.d.ts.map +1 -0
- package/dist/cjs/page-transition/variants.js +330 -0
- package/dist/cjs/page-transition/variants.js.map +1 -0
- package/dist/cjs/page-transition/view-transition-css.d.ts +21 -0
- package/dist/cjs/page-transition/view-transition-css.d.ts.map +1 -0
- package/dist/cjs/page-transition/view-transition-css.js +188 -0
- package/dist/cjs/page-transition/view-transition-css.js.map +1 -0
- package/dist/cjs/scroll-scene/chapter-index.d.ts +15 -0
- package/dist/cjs/scroll-scene/chapter-index.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/chapter-index.js +30 -0
- package/dist/cjs/scroll-scene/chapter-index.js.map +1 -0
- package/dist/cjs/scroll-scene/controller-source.d.ts +26 -0
- package/dist/cjs/scroll-scene/controller-source.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/controller-source.js +34 -0
- package/dist/cjs/scroll-scene/controller-source.js.map +1 -0
- package/dist/cjs/scroll-scene/engine-source.d.ts +2 -0
- package/dist/cjs/scroll-scene/engine-source.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/engine-source.js +23 -0
- package/dist/cjs/scroll-scene/engine-source.js.map +1 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.d.ts +9 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.js +16 -0
- package/dist/cjs/scroll-scene/helper-sources.generated.js.map +1 -0
- package/dist/cjs/scroll-scene/index.d.ts +8 -0
- package/dist/cjs/scroll-scene/index.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/index.js +24 -0
- package/dist/cjs/scroll-scene/index.js.map +1 -0
- package/dist/cjs/scroll-scene/moment.d.ts +21 -0
- package/dist/cjs/scroll-scene/moment.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/moment.js +50 -0
- package/dist/cjs/scroll-scene/moment.js.map +1 -0
- package/dist/cjs/scroll-scene/points.d.ts +23 -0
- package/dist/cjs/scroll-scene/points.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/points.js +51 -0
- package/dist/cjs/scroll-scene/points.js.map +1 -0
- package/dist/cjs/scroll-scene/unclip.d.ts +15 -0
- package/dist/cjs/scroll-scene/unclip.d.ts.map +1 -0
- package/dist/cjs/scroll-scene/unclip.js +44 -0
- package/dist/cjs/scroll-scene/unclip.js.map +1 -0
- package/dist/cjs/state-bindings/index.d.ts +74 -0
- package/dist/cjs/state-bindings/index.d.ts.map +1 -0
- package/dist/cjs/state-bindings/index.js +193 -0
- package/dist/cjs/state-bindings/index.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/motion-runtime/index.d.ts +3 -0
- package/dist/esm/motion-runtime/index.d.ts.map +1 -0
- package/dist/esm/motion-runtime/index.js +3 -0
- package/dist/esm/motion-runtime/index.js.map +1 -0
- package/dist/esm/motion-runtime/motion-engine-source.d.ts +16 -0
- package/dist/esm/motion-runtime/motion-engine-source.d.ts.map +1 -0
- package/dist/esm/motion-runtime/motion-engine-source.js +16 -0
- package/dist/esm/motion-runtime/motion-engine-source.js.map +1 -0
- package/dist/esm/motion-runtime/scroll-video-engine-source.d.ts +9 -0
- package/dist/esm/motion-runtime/scroll-video-engine-source.d.ts.map +1 -0
- package/dist/esm/motion-runtime/scroll-video-engine-source.js +9 -0
- package/dist/esm/motion-runtime/scroll-video-engine-source.js.map +1 -0
- package/dist/esm/page-transition/index.d.ts +5 -0
- package/dist/esm/page-transition/index.d.ts.map +1 -0
- package/dist/esm/page-transition/index.js +5 -0
- package/dist/esm/page-transition/index.js.map +1 -0
- package/dist/esm/page-transition/morph-source.d.ts +20 -0
- package/dist/esm/page-transition/morph-source.d.ts.map +1 -0
- package/dist/esm/page-transition/morph-source.js +21 -0
- package/dist/esm/page-transition/morph-source.js.map +1 -0
- package/dist/esm/page-transition/variant-sources.generated.d.ts +7 -0
- package/dist/esm/page-transition/variant-sources.generated.d.ts.map +1 -0
- package/dist/esm/page-transition/variant-sources.generated.js +11 -0
- package/dist/esm/page-transition/variant-sources.generated.js.map +1 -0
- package/dist/esm/page-transition/variants.d.ts +87 -0
- package/dist/esm/page-transition/variants.d.ts.map +1 -0
- package/dist/esm/page-transition/variants.js +318 -0
- package/dist/esm/page-transition/variants.js.map +1 -0
- package/dist/esm/page-transition/view-transition-css.d.ts +21 -0
- package/dist/esm/page-transition/view-transition-css.d.ts.map +1 -0
- package/dist/esm/page-transition/view-transition-css.js +161 -0
- package/dist/esm/page-transition/view-transition-css.js.map +1 -0
- package/dist/esm/scroll-scene/chapter-index.d.ts +15 -0
- package/dist/esm/scroll-scene/chapter-index.d.ts.map +1 -0
- package/dist/esm/scroll-scene/chapter-index.js +26 -0
- package/dist/esm/scroll-scene/chapter-index.js.map +1 -0
- package/dist/esm/scroll-scene/controller-source.d.ts +26 -0
- package/dist/esm/scroll-scene/controller-source.d.ts.map +1 -0
- package/dist/esm/scroll-scene/controller-source.js +26 -0
- package/dist/esm/scroll-scene/controller-source.js.map +1 -0
- package/dist/esm/scroll-scene/engine-source.d.ts +2 -0
- package/dist/esm/scroll-scene/engine-source.d.ts.map +1 -0
- package/dist/esm/scroll-scene/engine-source.js +19 -0
- package/dist/esm/scroll-scene/engine-source.js.map +1 -0
- package/dist/esm/scroll-scene/helper-sources.generated.d.ts +9 -0
- package/dist/esm/scroll-scene/helper-sources.generated.d.ts.map +1 -0
- package/dist/esm/scroll-scene/helper-sources.generated.js +13 -0
- package/dist/esm/scroll-scene/helper-sources.generated.js.map +1 -0
- package/dist/esm/scroll-scene/index.d.ts +8 -0
- package/dist/esm/scroll-scene/index.d.ts.map +1 -0
- package/dist/esm/scroll-scene/index.js +8 -0
- package/dist/esm/scroll-scene/index.js.map +1 -0
- package/dist/esm/scroll-scene/moment.d.ts +21 -0
- package/dist/esm/scroll-scene/moment.d.ts.map +1 -0
- package/dist/esm/scroll-scene/moment.js +46 -0
- package/dist/esm/scroll-scene/moment.js.map +1 -0
- package/dist/esm/scroll-scene/points.d.ts +23 -0
- package/dist/esm/scroll-scene/points.d.ts.map +1 -0
- package/dist/esm/scroll-scene/points.js +45 -0
- package/dist/esm/scroll-scene/points.js.map +1 -0
- package/dist/esm/scroll-scene/unclip.d.ts +15 -0
- package/dist/esm/scroll-scene/unclip.d.ts.map +1 -0
- package/dist/esm/scroll-scene/unclip.js +40 -0
- package/dist/esm/scroll-scene/unclip.js.map +1 -0
- package/dist/esm/state-bindings/index.d.ts +74 -0
- package/dist/esm/state-bindings/index.d.ts.map +1 -0
- package/dist/esm/state-bindings/index.js +176 -0
- package/dist/esm/state-bindings/index.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/index.ts +8 -0
- package/src/motion-runtime/index.ts +2 -0
- package/src/motion-runtime/motion-engine-source.ts +289 -0
- package/src/motion-runtime/scroll-video-engine-source.ts +591 -0
- package/src/page-transition/index.ts +4 -0
- package/src/page-transition/morph-source.ts +86 -0
- package/src/page-transition/variant-sources.generated.ts +14 -0
- package/src/page-transition/variants.ts +407 -0
- package/src/page-transition/view-transition-css.ts +237 -0
- package/src/scroll-scene/chapter-index.ts +25 -0
- package/src/scroll-scene/controller-source.ts +451 -0
- package/src/scroll-scene/engine-source.ts +327 -0
- package/src/scroll-scene/helper-sources.generated.ts +18 -0
- package/src/scroll-scene/index.ts +13 -0
- package/src/scroll-scene/moment.ts +64 -0
- package/src/scroll-scene/points.ts +46 -0
- package/src/scroll-scene/unclip.ts +44 -0
- package/src/state-bindings/index.ts +207 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.viewTransitionPlan = exports.MORPH_NAME = exports.ORIGIN_Y = exports.ORIGIN_X = exports.BACK_ATTR = void 0;
|
|
47
|
+
var PageTransition = __importStar(require("./variants"));
|
|
48
|
+
exports.BACK_ATTR = 'data-tq-nav';
|
|
49
|
+
exports.ORIGIN_X = '--tq-origin-x';
|
|
50
|
+
exports.ORIGIN_Y = '--tq-origin-y';
|
|
51
|
+
var hasAny = function (state, keys) {
|
|
52
|
+
return keys.some(function (key) { return state[key] !== undefined; });
|
|
53
|
+
};
|
|
54
|
+
/** One keyframe. Both ends of an animation declare the same properties, so every one of them interpolates. */
|
|
55
|
+
var declarations = function (state, other) {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f;
|
|
57
|
+
var lines = [];
|
|
58
|
+
var both = function (keys) { return hasAny(state, keys) || hasAny(other, keys); };
|
|
59
|
+
if (both(['opacity'])) {
|
|
60
|
+
lines.push("opacity: ".concat((_a = state.opacity) !== null && _a !== void 0 ? _a : 1, ";"));
|
|
61
|
+
}
|
|
62
|
+
if (both(['x', 'y', 'scale'])) {
|
|
63
|
+
lines.push("transform: translate(".concat((_b = state.x) !== null && _b !== void 0 ? _b : 0, "px, ").concat((_c = state.y) !== null && _c !== void 0 ? _c : 0, "px) scale(").concat((_d = state.scale) !== null && _d !== void 0 ? _d : 1, ");"));
|
|
64
|
+
}
|
|
65
|
+
if (both(['filter'])) {
|
|
66
|
+
lines.push("filter: ".concat((_e = state.filter) !== null && _e !== void 0 ? _e : 'blur(0px)', ";"));
|
|
67
|
+
}
|
|
68
|
+
if (both(['clipPath'])) {
|
|
69
|
+
lines.push("clip-path: ".concat((_f = state.clipPath) !== null && _f !== void 0 ? _f : 'inset(0 0 0 0)', ";"));
|
|
70
|
+
}
|
|
71
|
+
return lines;
|
|
72
|
+
};
|
|
73
|
+
var keyframes = function (name, from, to) {
|
|
74
|
+
return "@keyframes ".concat(name, " {\n from { ").concat(declarations(from, to).join(' '), " }\n to { ").concat(declarations(to, from).join(' '), " }\n}");
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The cover family in the Next export is one or two coloured panels that close
|
|
78
|
+
* over the leaving page and open on the arriving one. A picture of a page can
|
|
79
|
+
* be clipped, so here the panel is what shows where the picture is clipped
|
|
80
|
+
* away: the colour sits behind both pictures and the clip edge is the panel's
|
|
81
|
+
* leading edge. Same sweep, same colour, no extra element on any page.
|
|
82
|
+
*/
|
|
83
|
+
var COVER_CLIPS = {
|
|
84
|
+
// one panel rising from the bottom, then leaving through the top
|
|
85
|
+
cover: { covered: 'inset(0 0 100% 0)', opening: 'inset(100% 0 0 0)' },
|
|
86
|
+
// two panels meeting in the middle, then parting
|
|
87
|
+
curtain: { covered: 'inset(0 50% 0 50%)', opening: 'inset(0 50% 0 50%)' },
|
|
88
|
+
};
|
|
89
|
+
var OPEN = 'inset(0 0 0 0)';
|
|
90
|
+
var animationsFor = function (preset, context, options, custom) {
|
|
91
|
+
var cover = COVER_CLIPS[preset];
|
|
92
|
+
if (cover) {
|
|
93
|
+
return {
|
|
94
|
+
leave: [{ clipPath: OPEN }, { clipPath: cover.covered }],
|
|
95
|
+
arrive: [{ clipPath: cover.opening }, { clipPath: OPEN }],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
var variants = PageTransition.pageTransitionVariants(preset, PageTransition.PAGE_TRANSITION_SLIDE_PX, context, options, custom);
|
|
99
|
+
if (!variants) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
leave: [variants.animate, variants.exit],
|
|
104
|
+
arrive: [variants.initial, variants.animate],
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/** The name of the one image that flies from the leaving page into the arriving page. */
|
|
108
|
+
exports.MORPH_NAME = 'tq-morph';
|
|
109
|
+
var viewTransitionPlan = function (config, target) {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
if (target === void 0) { target = { crossDocument: true }; }
|
|
112
|
+
var preset = String(config.preset).replace(/[^a-z-]/g, '');
|
|
113
|
+
var chosen = config.options && typeof config.options === 'object'
|
|
114
|
+
? Object.fromEntries(Object.entries(config.options).filter(function (_a) {
|
|
115
|
+
var value = _a[1];
|
|
116
|
+
return typeof value === 'string';
|
|
117
|
+
}))
|
|
118
|
+
: undefined;
|
|
119
|
+
var options = PageTransition.resolvePageTransitionOptions(preset, chosen);
|
|
120
|
+
var duration = Number.isFinite(config.duration) && config.duration > 0 ? config.duration : 0.35;
|
|
121
|
+
var curve = PageTransition.PAGE_TRANSITION_EASING_CURVES[config.easing] ||
|
|
122
|
+
PageTransition.PAGE_TRANSITION_EASING_CURVES['ease-out'];
|
|
123
|
+
var custom = preset === 'custom'
|
|
124
|
+
? PageTransition.sanitizePageTransitionCustom({
|
|
125
|
+
durationSeconds: duration,
|
|
126
|
+
easing: config.easing,
|
|
127
|
+
arrive: (_a = config.custom) === null || _a === void 0 ? void 0 : _a.arrive,
|
|
128
|
+
leave: (_b = config.custom) === null || _b === void 0 ? void 0 : _b.leave,
|
|
129
|
+
})
|
|
130
|
+
: undefined;
|
|
131
|
+
var needsOrigin = preset === 'circle' && options.origin !== 'center';
|
|
132
|
+
var origin = needsOrigin
|
|
133
|
+
? { originX: "var(".concat(exports.ORIGIN_X, ", 50%)"), originY: "var(".concat(exports.ORIGIN_Y, ", 50%)") }
|
|
134
|
+
: { originX: '50%', originY: '50%' };
|
|
135
|
+
var forward = animationsFor(preset, __assign({ reverse: false }, origin), options, custom);
|
|
136
|
+
if (!forward) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
var needsDirection = PageTransition.reversePageTransitionPreset(preset) !== preset;
|
|
140
|
+
var back = needsDirection
|
|
141
|
+
? animationsFor(preset, { reverse: true, originX: '50%', originY: '50%' }, options, custom)
|
|
142
|
+
: null;
|
|
143
|
+
var timing = "".concat(duration, "s cubic-bezier(").concat(curve.join(', '), ")");
|
|
144
|
+
// A reveal opens the arriving page over the leaving one: only the arrival
|
|
145
|
+
// animates, from the start, and the leaving picture just stays.
|
|
146
|
+
var revealsOver = !COVER_CLIPS[preset] && forward.arrive[1].clipPath !== undefined;
|
|
147
|
+
var arriveTiming = revealsOver ? "".concat(timing, " both") : "".concat(timing, " ").concat(duration, "s both");
|
|
148
|
+
var rules = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], (target.crossDocument ? ['@view-transition {\n navigation: auto;\n}'] : []), true), [
|
|
149
|
+
'::view-transition-old(root),\n::view-transition-new(root) {\n mix-blend-mode: normal;\n}',
|
|
150
|
+
revealsOver
|
|
151
|
+
? '::view-transition-old(root) {\n animation: none;\n}'
|
|
152
|
+
: "::view-transition-old(root) {\n animation: tq-page-leave ".concat(timing, " both;\n}"),
|
|
153
|
+
"::view-transition-new(root) {\n animation: tq-page-arrive ".concat(arriveTiming, ";\n}")
|
|
154
|
+
], false), (revealsOver ? [] : [keyframes('tq-page-leave', forward.leave[0], forward.leave[1])]), true), [
|
|
155
|
+
keyframes('tq-page-arrive', forward.arrive[0], forward.arrive[1]),
|
|
156
|
+
], false);
|
|
157
|
+
if (COVER_CLIPS[preset]) {
|
|
158
|
+
rules.push("::view-transition-group(root) {\n background: ".concat(PageTransition.pageTransitionCoverColor(options.color), ";\n}"));
|
|
159
|
+
}
|
|
160
|
+
if (back) {
|
|
161
|
+
if (!revealsOver) {
|
|
162
|
+
rules.push("html[".concat(exports.BACK_ATTR, "=\"back\"]::view-transition-old(root) {\n animation-name: tq-page-leave-back;\n}"));
|
|
163
|
+
}
|
|
164
|
+
rules.push.apply(rules, __spreadArray(__spreadArray(["html[".concat(exports.BACK_ATTR, "=\"back\"]::view-transition-new(root) {\n animation-name: tq-page-arrive-back;\n}")], (revealsOver ? [] : [keyframes('tq-page-leave-back', back.leave[0], back.leave[1])]), false), [keyframes('tq-page-arrive-back', back.arrive[0], back.arrive[1])], false));
|
|
165
|
+
}
|
|
166
|
+
// The flying image spans both halves (the leaving page's and the arriving
|
|
167
|
+
// page's — one half when the arrival plays over the leaving page), and a
|
|
168
|
+
// card's 4:3 picture grows into a 16:9 hero cropped, never stretched. A
|
|
169
|
+
// picture the arriving page does not show has nowhere to land: it leaves
|
|
170
|
+
// with its page instead of lingering over the next one.
|
|
171
|
+
var flies = config.flyingPictures !== false;
|
|
172
|
+
if (flies) {
|
|
173
|
+
var flight = revealsOver ? duration : duration * 2;
|
|
174
|
+
rules.push("::view-transition-group(".concat(exports.MORPH_NAME, ") {\n animation-duration: ").concat(flight, "s;\n animation-timing-function: cubic-bezier(").concat(curve.join(', '), ");\n}"), "::view-transition-old(".concat(exports.MORPH_NAME, "),\n::view-transition-new(").concat(exports.MORPH_NAME, ") {\n height: 100%;\n object-fit: cover;\n overflow: clip;\n animation-duration: ").concat(flight, "s;\n}"), revealsOver
|
|
175
|
+
? "::view-transition-old(".concat(exports.MORPH_NAME, "):only-child {\n animation: tq-morph-away ").concat(timing, " both;\n}")
|
|
176
|
+
: "::view-transition-old(".concat(exports.MORPH_NAME, "):only-child {\n animation: tq-page-leave ").concat(timing, " both, tq-morph-away ").concat(timing, " both;\n}"), "::view-transition-new(".concat(exports.MORPH_NAME, "):only-child {\n animation: tq-page-arrive ").concat(arriveTiming, ", tq-morph-in ").concat(arriveTiming, ";\n}"), '@keyframes tq-morph-away {\n to { opacity: 0; }\n}', '@keyframes tq-morph-in {\n from { opacity: 0; }\n}');
|
|
177
|
+
}
|
|
178
|
+
var indented = rules.map(function (rule) { return rule.replace(/^/gm, ' '); }).join('\n');
|
|
179
|
+
return {
|
|
180
|
+
css: "@media (prefers-reduced-motion: no-preference) {\n".concat(indented, "\n}\n"),
|
|
181
|
+
needsDirection: needsDirection,
|
|
182
|
+
needsOrigin: needsOrigin,
|
|
183
|
+
flies: flies,
|
|
184
|
+
revealsOver: revealsOver,
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
exports.viewTransitionPlan = viewTransitionPlan;
|
|
188
|
+
//# sourceMappingURL=view-transition-css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-transition-css.js","sourceRoot":"","sources":["../../../src/page-transition/view-transition-css.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA4C;AAkC/B,QAAA,SAAS,GAAG,aAAa,CAAA;AACzB,QAAA,QAAQ,GAAG,eAAe,CAAA;AAC1B,QAAA,QAAQ,GAAG,eAAe,CAAA;AAEvC,IAAM,MAAM,GAAG,UAAC,KAAY,EAAE,IAAc;IAC1C,OAAA,IAAI,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,EAAxB,CAAwB,CAAC;AAA5C,CAA4C,CAAA;AAE9C,8GAA8G;AAC9G,IAAM,YAAY,GAAG,UAAC,KAAY,EAAE,KAAY;;IAC9C,IAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAM,IAAI,GAAG,UAAC,IAAc,IAAK,OAAA,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EAA1C,CAA0C,CAAA;IAC3E,IAAI,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE;QACrB,KAAK,CAAC,IAAI,CAAC,mBAAY,MAAA,KAAK,CAAC,OAAO,mCAAI,CAAC,MAAG,CAAC,CAAA;KAC9C;IACD,IAAI,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE;QAC7B,KAAK,CAAC,IAAI,CACR,+BAAwB,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,iBAAO,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,uBAAa,MAAA,KAAK,CAAC,KAAK,mCAAI,CAAC,OAAI,CACzF,CAAA;KACF;IACD,IAA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E,cAAc,gBAAA;QACd,WAAW,aAAA;QACX,KAAK,OAAA;QACL,WAAW,aAAA;KACZ,CAAA;AACH,CAAC,CAAA;AAxGY,QAAA,kBAAkB,sBAwG9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which chapter is ON STAGE at a scene progress: the chapter whose moment is
|
|
3
|
+
* the latest one the visitor has passed (a later chapter wins a tie), -1 before
|
|
4
|
+
* any moment is reached. Moments are read in document order but need not be
|
|
5
|
+
* monotone — an author's "Snap here" can put an early chapter's moment late.
|
|
6
|
+
* The published TqScrollScene announces every change of this index as a
|
|
7
|
+
* `tq-chapter-reached` DOM event on the chapter element — the hook the
|
|
8
|
+
* "A Chapter Is Reached" workflow trigger listens for.
|
|
9
|
+
*
|
|
10
|
+
* Plain JS inside: this function's SOURCE is injected into the generated
|
|
11
|
+
* runtime via toString(), so no TypeScript-only runtime constructs and no
|
|
12
|
+
* template literals.
|
|
13
|
+
*/
|
|
14
|
+
export declare function activeChapterIndex(moments: number[], progress: number): number;
|
|
15
|
+
//# sourceMappingURL=chapter-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chapter-index.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/chapter-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAW9E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activeChapterIndex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Which chapter is ON STAGE at a scene progress: the chapter whose moment is
|
|
6
|
+
* the latest one the visitor has passed (a later chapter wins a tie), -1 before
|
|
7
|
+
* any moment is reached. Moments are read in document order but need not be
|
|
8
|
+
* monotone — an author's "Snap here" can put an early chapter's moment late.
|
|
9
|
+
* The published TqScrollScene announces every change of this index as a
|
|
10
|
+
* `tq-chapter-reached` DOM event on the chapter element — the hook the
|
|
11
|
+
* "A Chapter Is Reached" workflow trigger listens for.
|
|
12
|
+
*
|
|
13
|
+
* Plain JS inside: this function's SOURCE is injected into the generated
|
|
14
|
+
* runtime via toString(), so no TypeScript-only runtime constructs and no
|
|
15
|
+
* template literals.
|
|
16
|
+
*/
|
|
17
|
+
function activeChapterIndex(moments, progress) {
|
|
18
|
+
var active = -1;
|
|
19
|
+
var best = -Infinity;
|
|
20
|
+
for (var index = 0; index < moments.length; index++) {
|
|
21
|
+
var moment = moments[index];
|
|
22
|
+
if (moment <= progress + 0.000001 && moment >= best) {
|
|
23
|
+
best = moment;
|
|
24
|
+
active = index;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return active;
|
|
28
|
+
}
|
|
29
|
+
exports.activeChapterIndex = activeChapterIndex;
|
|
30
|
+
//# sourceMappingURL=chapter-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chapter-index.js","sourceRoot":"","sources":["../../../src/scroll-scene/chapter-index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACH,SAAgB,kBAAkB,CAAC,OAAiB,EAAE,QAAgB;IACpE,IAAI,MAAM,GAAG,CAAC,CAAC,CAAA;IACf,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAA;IACpB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACnD,IAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;QAC7B,IAAI,MAAM,IAAI,QAAQ,GAAG,QAAQ,IAAI,MAAM,IAAI,IAAI,EAAE;YACnD,IAAI,GAAG,MAAM,CAAA;YACb,MAAM,GAAG,KAAK,CAAA;SACf;KACF;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAXD,gDAWC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of a scroll scene's controller that are plain DOM JavaScript, as
|
|
3
|
+
* SOURCE TEXT, shared word for word by the Next export's TqScrollScene and the
|
|
4
|
+
* HTML export's vanilla controller. Each block talks to its surroundings through
|
|
5
|
+
* the same names in both hosts:
|
|
6
|
+
*
|
|
7
|
+
* trackRef, progressRef, chapterHelpersRef, chapterStateRef,
|
|
8
|
+
* scenePointStateRef, awaitedTagsRef, restackRef objects with a `current`
|
|
9
|
+
* pin, layout, chapterSnap, shouldReduceMotion the scene's settings
|
|
10
|
+
*
|
|
11
|
+
* In React those are refs and props; in the HTML runtime they are plain objects
|
|
12
|
+
* and constants of the same names. The engine (engine-source.ts) must be in
|
|
13
|
+
* scope. Bodies that were React effects keep their early `return undefined` and
|
|
14
|
+
* their returned cleanup, so a host wraps them in a function.
|
|
15
|
+
*/
|
|
16
|
+
/** Scene points and chapters announced as DOM events, with the stamps late listeners read. */
|
|
17
|
+
export declare const announcementsSource: () => string;
|
|
18
|
+
/** Body of `restack`: every real grid item of a chapters stage goes into the same cell. */
|
|
19
|
+
export declare const restackBodySource: () => string;
|
|
20
|
+
/** Chapter geometry: where a chapter is on stage, which children are chapters, how to scroll there. */
|
|
21
|
+
export declare const chapterHelpersSource: () => string;
|
|
22
|
+
/** Body of the anchor-navigation effect: a hash that points into a pinned scene scrolls to that chapter. */
|
|
23
|
+
export declare const anchorNavigationBodySource: () => string;
|
|
24
|
+
/** Body of the gentle chapter-snap effect: a visitor who pauses mid-scene settles on the nearest chapter. */
|
|
25
|
+
export declare const gentleSnapBodySource: () => string;
|
|
26
|
+
//# sourceMappingURL=controller-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-source.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/controller-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,QAC1B,MAwJF,CAAA;AAEJ,2FAA2F;AAC3F,eAAO,MAAM,iBAAiB,QACxB,MAsDwC,CAAA;AAE9C,uGAAuG;AACvG,eAAO,MAAM,oBAAoB,QAAO,MAgFpC,CAAA;AAEJ,4GAA4G;AAC5G,eAAO,MAAM,0BAA0B,QAAO,MA2ExC,CAAA;AAEN,6GAA6G;AAC7G,eAAO,MAAM,oBAAoB,QAAO,MA0DlC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The parts of a scroll scene's controller that are plain DOM JavaScript, as
|
|
4
|
+
* SOURCE TEXT, shared word for word by the Next export's TqScrollScene and the
|
|
5
|
+
* HTML export's vanilla controller. Each block talks to its surroundings through
|
|
6
|
+
* the same names in both hosts:
|
|
7
|
+
*
|
|
8
|
+
* trackRef, progressRef, chapterHelpersRef, chapterStateRef,
|
|
9
|
+
* scenePointStateRef, awaitedTagsRef, restackRef objects with a `current`
|
|
10
|
+
* pin, layout, chapterSnap, shouldReduceMotion the scene's settings
|
|
11
|
+
*
|
|
12
|
+
* In React those are refs and props; in the HTML runtime they are plain objects
|
|
13
|
+
* and constants of the same names. The engine (engine-source.ts) must be in
|
|
14
|
+
* scope. Bodies that were React effects keep their early `return undefined` and
|
|
15
|
+
* their returned cleanup, so a host wraps them in a function.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.gentleSnapBodySource = exports.anchorNavigationBodySource = exports.chapterHelpersSource = exports.restackBodySource = exports.announcementsSource = void 0;
|
|
19
|
+
/** Scene points and chapters announced as DOM events, with the stamps late listeners read. */
|
|
20
|
+
var announcementsSource = function () { return " // Announces the points passed on the way down, in scroll order, one\n // microtask later (the ancestors' effects, where generated listeners attach,\n // have run by then). The stamp is written with the dispatch, never before it,\n // so a listener attaching in the same effect flush sees no stamp and gets the\n // event, while one attaching later reads the stamp and nothing is announced\n // twice. The first announcement measures from below the scene, so a page\n // that opens already past a point (an anchor link, a restored scroll) counts\n // it as passed. Going up announces nothing; the next way down announces again.\n const announceScenePoints = (p) => {\n const state = scenePointStateRef.current\n const from = state.last === null ? -1 : state.last\n state.last = p\n const passed = passedScenePoints(from, p)\n if (passed.length === 0) {\n return\n }\n state.pending = state.pending.concat(passed)\n if (state.scheduled) {\n return\n }\n state.scheduled = true\n Promise.resolve().then(() => {\n const current = scenePointStateRef.current\n current.scheduled = false\n const batch = current.pending\n current.pending = []\n const track = trackRef.current\n if (!track) {\n return\n }\n for (const key of batch) {\n if (scenePointRank(key) > scenePointRank(track.getAttribute(SCENE_POINT_ATTR) || '')) {\n track.setAttribute(SCENE_POINT_ATTR, key)\n }\n track.dispatchEvent(\n new CustomEvent(SCENE_POINT_EVENT, {\n bubbles: true,\n detail: { point: key, progress: current.last },\n })\n )\n }\n })\n }\n\n // The chapters in document order with the moment each one is on stage \u2014\n // the same moment chapter snap and anchor navigation aim at; a chapter\n // without a moment of its own takes the start of its even share.\n const chapterRecords = () => {\n const track = trackRef.current\n const helpers = chapterHelpersRef.current\n if (!track || !helpers) {\n return []\n }\n const chapters = helpers.chapterElements(track)\n return chapters.map((element, index) => {\n const moment = helpers.chapterProgress(element)\n return {\n element,\n moment:\n moment === null ? index / chapters.length : Math.min(1, Math.max(0, moment)),\n }\n })\n }\n\n // Announces chapters as the visitor passes their moments: every chapter\n // between the last announced one and the one now on stage gets its\n // tq-chapter-reached (bubbling) in travel order, so a jump past a chapter\n // still counts as reaching it. The current chapter carries\n // data-chapter-active / data-chapter-count for listeners that attach later.\n // Dispatch is deferred to a microtask: the ancestors' effects (where the\n // generated listeners attach) have run by then, and nothing is a frame late.\n const announceChapter = (p) => {\n const state = chapterStateRef.current\n if (state.records === null) {\n state.records = chapterRecords()\n state.moments = state.records.map((record) => record.moment)\n // A rebuilt list may hold NEW elements for the same chapters (a repeater\n // re-rendered): the stamp moves to the current chapter's new element\n // without announcing it again.\n const current = state.index >= 0 ? state.records[state.index] : null\n if (current && current.element !== state.element) {\n stampChapter(current.element, state.index + 1, state.records.length)\n } else if (!current && state.index >= 0) {\n state.index = -1\n state.element = null\n }\n }\n const direction = p >= state.lastProgress ? 'down' : 'up'\n state.lastProgress = p\n if (state.moments.length === 0 || !state.onScreen) {\n return\n }\n const next = activeChapterIndex(state.moments, p)\n if (next === state.index) {\n return\n }\n const from = state.index\n state.index = next\n if (next === -1) {\n stampChapter(null, 0, 0)\n return\n }\n const passed = []\n if (from < next) {\n for (let index = from + 1; index <= next; index++) {\n passed.push(index)\n }\n } else {\n for (let index = from - 1; index >= next; index--) {\n passed.push(index)\n }\n }\n stampChapter(state.records[next].element, next + 1, state.records.length)\n state.pending = { passed, progress: p, direction }\n Promise.resolve().then(() => {\n const batch = chapterStateRef.current.pending\n if (!batch) {\n return\n }\n chapterStateRef.current.pending = null\n const records = chapterStateRef.current.records || []\n for (const index of batch.passed) {\n const record = records[index]\n if (!record) {\n continue\n }\n record.element.dispatchEvent(\n new CustomEvent(CHAPTER_REACHED_EVENT, {\n bubbles: true,\n detail: {\n chapterIndex: index + 1,\n chapterCount: records.length,\n progress: batch.progress,\n direction: batch.direction,\n },\n })\n )\n }\n })\n }\n\n const stampChapter = (element, chapterIndex, chapterCount) => {\n const state = chapterStateRef.current\n if (state.element && state.element !== element) {\n state.element.removeAttribute(CHAPTER_ACTIVE_ATTR)\n state.element.removeAttribute(CHAPTER_COUNT_ATTR)\n }\n state.element = element\n if (element) {\n element.setAttribute(CHAPTER_ACTIVE_ATTR, String(chapterIndex))\n element.setAttribute(CHAPTER_COUNT_ATTR, String(chapterCount))\n }\n }"; };
|
|
21
|
+
exports.announcementsSource = announcementsSource;
|
|
22
|
+
/** Body of `restack`: every real grid item of a chapters stage goes into the same cell. */
|
|
23
|
+
var restackBodySource = function () { return " if (layout !== 'chapters' || !trackRef.current) {\n return\n }\n const stage = trackRef.current.querySelector(':scope > [data-scene-stage]')\n if (!stage) {\n return\n }\n const place = (el) => {\n // Duck-typed, never instanceof \u2014 mirrors the editor runtime, where\n // canvas elements belong to another realm and instanceof always fails.\n if (!el || el.nodeType !== 1 || el.tagName === 'STYLE') {\n return\n }\n if (!el.style || typeof el.style.removeProperty !== 'function') {\n return\n }\n let display = ''\n try {\n display = getComputedStyle(el).display\n } catch (e) {\n // detached node \u2014 skip\n }\n if (display === 'contents') {\n // A pre-upgrade pass may have pinned this wrapper as a box \u2014 clean up.\n if (el.style.gridArea) {\n el.style.removeProperty('grid-area')\n }\n if (el.shadowRoot) {\n Array.from(el.shadowRoot.children).forEach(place)\n return\n }\n if (typeof el.assignedElements === 'function') {\n const assigned = el.assignedElements({ flatten: true })\n ;(assigned.length > 0 ? assigned : Array.from(el.children)).forEach(place)\n return\n }\n Array.from(el.children).forEach(place)\n return\n }\n const tag = el.tagName.toLowerCase()\n if (\n tag.includes('-') &&\n typeof customElements !== 'undefined' &&\n !customElements.get(tag) &&\n !awaitedTagsRef.current.has(tag)\n ) {\n awaitedTagsRef.current.add(tag)\n customElements\n .whenDefined(tag)\n .then(() => restackRef.current && restackRef.current())\n .catch(() => undefined)\n }\n el.style.gridArea = '1 / 1'\n }\n Array.from(stage.children).forEach(place)"; };
|
|
24
|
+
exports.restackBodySource = restackBodySource;
|
|
25
|
+
/** Chapter geometry: where a chapter is on stage, which children are chapters, how to scroll there. */
|
|
26
|
+
var chapterHelpersSource = function () { return " if (chapterHelpersRef.current === null) {\n const chapterProgress = (chapterRoot) => {\n // 1. The author's own snap point (\"Snap here\" on the timeline) wins.\n const override = parseFloat(chapterRoot.getAttribute('data-chapter-moment') || '')\n if (Number.isFinite(override)) {\n return Math.min(1, Math.max(0, override))\n }\n // 2. The settled moment \u2014 everything arrived, nothing leaving \u2014 read\n // from the root's and every descendant's lanes.\n const boundLanes = []\n const boundElements = [chapterRoot].concat(\n Array.from(chapterRoot.querySelectorAll('[' + SCROLL_BIND_ATTR + ']'))\n )\n for (const element of boundElements) {\n const lanes = parseScrollBind(element.getAttribute(SCROLL_BIND_ATTR))\n for (const lane of lanes) {\n boundLanes.push(lane)\n }\n }\n const settled = settledMomentForLanes(boundLanes)\n if (settled !== null) {\n return settled\n }\n // 3. Through-motion only (a crossing line): the window's middle.\n const recorded = String(chapterRoot.getAttribute('data-chapter-window') || '')\n .split(',')\n .map((part) => parseFloat(part))\n if (recorded.length === 2 && recorded.every((value) => Number.isFinite(value))) {\n return (recorded[0] + recorded[1]) / 2\n }\n const lanes = parseScrollBind(chapterRoot.getAttribute(SCROLL_BIND_ATTR))\n const stops = lanes.flatMap((lane) => lane.at)\n if (stops.length === 0) {\n return null\n }\n return (Math.min.apply(null, stops) + Math.max.apply(null, stops)) / 2\n }\n chapterHelpersRef.current = {\n stageOf: (track) => track.querySelector(':scope > [data-scene-stage]'),\n chapterProgress,\n // The chapters: the stage's children when the scene pins, the track's own\n // children when it does not. Never the style tag, never a backdrop: the\n // background video, a bare media child (img / video / picture) or any\n // child marked data-scene-backdrop is the scene's background \u2014 it sits\n // under the chapters and owns no story window.\n chapterElements: (track) => {\n const stage = chapterHelpersRef.current.stageOf(track)\n const host = stage || track\n return Array.from(host.children).filter(\n (child) =>\n !!child.getAttribute &&\n child.tagName !== 'STYLE' &&\n child.tagName !== 'IMG' &&\n child.tagName !== 'VIDEO' &&\n child.tagName !== 'PICTURE' &&\n !child.hasAttribute('data-scroll-video') &&\n !child.hasAttribute('data-scene-backdrop') &&\n !child.hasAttribute('data-scene-stage')\n )\n },\n chapterMoments: (track) => {\n const moments = []\n for (const child of chapterHelpersRef.current.chapterElements(track)) {\n const progress = chapterProgress(child)\n if (progress !== null) {\n moments.push(Math.min(1, Math.max(0, progress)))\n }\n }\n return moments.sort((a, b) => a - b)\n },\n scrollToProgress: (track, progress, behavior) => {\n const rect = track.getBoundingClientRect()\n const trackTop = rect.top + window.scrollY\n const travel = Math.max(0, track.offsetHeight - window.innerHeight)\n window.scrollTo({\n top: trackTop + Math.min(1, Math.max(0, progress)) * travel,\n behavior,\n })\n },\n }\n }"; };
|
|
27
|
+
exports.chapterHelpersSource = chapterHelpersSource;
|
|
28
|
+
/** Body of the anchor-navigation effect: a hash that points into a pinned scene scrolls to that chapter. */
|
|
29
|
+
var anchorNavigationBodySource = function () { return " const track = trackRef.current\n if (!track || !pin || typeof window === 'undefined') {\n return undefined\n }\n const helpers = chapterHelpersRef.current\n const chapterRootFor = (target) => {\n const stage = helpers.stageOf(track)\n if (!stage || !stage.contains(target)) {\n return null\n }\n let current = target\n while (current && current.parentElement !== stage) {\n current = current.parentElement\n }\n return current\n }\n const scrollToChapter = (id, behavior) => {\n const target = id ? document.getElementById(id) : null\n const chapterRoot = target ? chapterRootFor(target) : null\n if (!chapterRoot) {\n return false\n }\n const progress = helpers.chapterProgress(chapterRoot)\n if (progress === null) {\n return false\n }\n helpers.scrollToProgress(track, progress, behavior)\n return true\n }\n const onClick = (event) => {\n if (event.defaultPrevented || event.button !== 0) {\n return\n }\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return\n }\n const anchor = event.target && event.target.closest ? event.target.closest('a[href]') : null\n if (!anchor) {\n return\n }\n const href = anchor.getAttribute('href') || ''\n const hashIndex = href.indexOf('#')\n if (hashIndex === -1) {\n return\n }\n const beforeHash = href.slice(0, hashIndex)\n if (beforeHash && beforeHash !== window.location.pathname) {\n return\n }\n const id = decodeURIComponent(href.slice(hashIndex + 1))\n if (scrollToChapter(id, 'smooth')) {\n event.preventDefault()\n try {\n window.history.pushState(null, '', '#' + id)\n } catch (e) {\n // history can refuse in sandboxed frames; the scroll already happened\n }\n }\n }\n const onHashChange = () => {\n scrollToChapter(decodeURIComponent(window.location.hash.slice(1)), 'smooth')\n }\n document.addEventListener('click', onClick, true)\n window.addEventListener('hashchange', onHashChange)\n let settleTimer = 0\n const initialId = decodeURIComponent(window.location.hash.slice(1))\n if (initialId) {\n window.requestAnimationFrame(() => scrollToChapter(initialId, 'auto'))\n // late images/fonts shift the track's document position \u2014 one correction\n settleTimer = window.setTimeout(() => scrollToChapter(initialId, 'auto'), 350)\n }\n return () => {\n document.removeEventListener('click', onClick, true)\n window.removeEventListener('hashchange', onHashChange)\n window.clearTimeout(settleTimer)\n }"; };
|
|
30
|
+
exports.anchorNavigationBodySource = anchorNavigationBodySource;
|
|
31
|
+
/** Body of the gentle chapter-snap effect: a visitor who pauses mid-scene settles on the nearest chapter. */
|
|
32
|
+
var gentleSnapBodySource = function () { return " const track = trackRef.current\n if (!track || !pin || chapterSnap !== 'gentle' || typeof window === 'undefined') {\n return undefined\n }\n if (shouldReduceMotion) {\n return undefined\n }\n const helpers = chapterHelpersRef.current\n let settleTimer = 0\n let suppressUntil = 0\n let lastProgress = progressRef.current\n let direction = 0\n const settle = () => {\n if (Date.now() < suppressUntil) {\n return\n }\n const progress = progressRef.current\n if (progress <= 0.001 || progress >= 0.999) {\n return\n }\n const moments = helpers.chapterMoments(track)\n if (moments.length === 0) {\n return\n }\n // Settle in the direction the visitor was travelling: a short scroll\n // forward lands on the next chapter, never back on the one just left.\n const ahead = moments.filter((moment) =>\n direction > 0 ? moment >= progress - 0.02 : direction < 0 ? moment <= progress + 0.02 : true\n )\n const candidates = ahead.length > 0 ? ahead : moments\n let nearest = candidates[0]\n for (const moment of candidates) {\n if (Math.abs(moment - progress) < Math.abs(nearest - progress)) {\n nearest = moment\n }\n }\n if (Math.abs(nearest - progress) < 0.005) {\n return\n }\n suppressUntil = Date.now() + 900\n helpers.scrollToProgress(track, nearest, 'smooth')\n }\n const onScroll = () => {\n window.clearTimeout(settleTimer)\n const progress = progressRef.current\n if (progress !== lastProgress) {\n direction = progress > lastProgress ? 1 : -1\n lastProgress = progress\n }\n if (Date.now() < suppressUntil) {\n return\n }\n settleTimer = window.setTimeout(settle, 180)\n }\n window.addEventListener('scroll', onScroll, { passive: true })\n return () => {\n window.removeEventListener('scroll', onScroll)\n window.clearTimeout(settleTimer)\n }"; };
|
|
33
|
+
exports.gentleSnapBodySource = gentleSnapBodySource;
|
|
34
|
+
//# sourceMappingURL=controller-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-source.js","sourceRoot":"","sources":["../../../src/scroll-scene/controller-source.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8FAA8F;AACvF,IAAM,mBAAmB,GAC9B,cAAc,OAAA,ynLAwJZ,EAxJY,CAwJZ,CAAA;AAzJS,QAAA,mBAAmB,uBAyJ5B;AAEJ,2FAA2F;AACpF,IAAM,iBAAiB,GAC5B,cAAc,OAAA,u2DAsD8B,EAtD9B,CAsD8B,CAAA;AAvDjC,QAAA,iBAAiB,qBAuDgB;AAE9C,uGAAuG;AAChG,IAAM,oBAAoB,GAAG,cAAc,OAAA,i+GAgF9C,EAhF8C,CAgF9C,CAAA;AAhFS,QAAA,oBAAoB,wBAgF7B;AAEJ,4GAA4G;AACrG,IAAM,0BAA0B,GAAG,cAAc,OAAA,ysFA2ElD,EA3EkD,CA2ElD,CAAA;AA3EO,QAAA,0BAA0B,8BA2EjC;AAEN,6GAA6G;AACtG,IAAM,oBAAoB,GAAG,cAAc,OAAA,g/DA0D5C,EA1D4C,CA0D5C,CAAA;AA1DO,QAAA,oBAAoB,wBA0D3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-source.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/engine-source.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,uBAAuB,QAAO,MAoTzC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scrollSceneEngineSource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The scroll-scene lane engine as SOURCE TEXT: the constants, the lane presets
|
|
6
|
+
* and the functions that parse a `data-scroll-bind`, read a lane at a progress
|
|
7
|
+
* and write it onto an element. It is plain DOM JavaScript with no framework in
|
|
8
|
+
* it, which is why two runtimes can share it word for word:
|
|
9
|
+
*
|
|
10
|
+
* - the Next export wraps it in the TqScrollScene React component, where
|
|
11
|
+
* framer-motion supplies the scroll progress;
|
|
12
|
+
* - the HTML export wraps it in a small vanilla controller, where a scroll
|
|
13
|
+
* listener supplies the same progress.
|
|
14
|
+
*
|
|
15
|
+
* One copy means a new lane property or preset reaches both exports at once.
|
|
16
|
+
* The text mirrors the canvas renderer's scroll-scene-lanes module, so the
|
|
17
|
+
* canvas, the Next site and the HTML site move identically. (No backticks in
|
|
18
|
+
* the engine's own comments: it is a template literal.)
|
|
19
|
+
*/
|
|
20
|
+
var helper_sources_generated_1 = require("./helper-sources.generated");
|
|
21
|
+
var scrollSceneEngineSource = function () { return "const SCROLL_BIND_ATTR = 'data-scroll-bind'\n// A chapter coming on stage is announced on the chapter element (bubbling), so\n// a workflow trigger bound to the chapter can listen without knowing the scene.\nconst CHAPTER_REACHED_EVENT = 'tq-chapter-reached'\nconst CHAPTER_ACTIVE_ATTR = 'data-chapter-active'\nconst CHAPTER_COUNT_ATTR = 'data-chapter-count'\n// Scrolling DOWN past a quarter / halfway / three quarters / the end of the\n// scene is announced on the track (the element with the scene's id), bubbling;\n// the furthest point passed so far is stamped for listeners that attach later.\nconst SCENE_POINT_EVENT = 'tq-scene-point-passed'\nconst SCENE_POINT_ATTR = 'data-scene-point'\n\nconst LANE_PROPS = [\n 'x',\n 'y',\n 'scale',\n 'rotate',\n 'rotate-x',\n 'rotate-y',\n 'opacity',\n 'blur',\n 'grayscale',\n 'saturate',\n 'brightness',\n 'clip',\n 'clip-y',\n 'count',\n]\n\n// Mirrors SCROLL_COUNT_ATTR / SCROLL_COUNT_CSS in the editor's lane contract.\nconst COUNT_ATTR = 'data-scroll-count'\nconst HIDDEN_ATTR = 'data-scene-hidden'\nconst HIDDEN_CSS =\n '[data-scene-hidden], [data-scene-hidden] * { pointer-events: none !important; }'\nconst COUNT_CSS =\n '[data-scroll-count]::before { counter-reset: tq-count var(--tq-count, 0); content: counter(tq-count); }'\nconst clampPercent = (value) => Math.min(100, Math.max(0, Math.round(value * 100) / 100))\n\nconst LANE_PRESETS = {\n 'depth-1': [{ prop: 'y', at: [0, 1], values: [40, -40] }],\n 'depth-2': [{ prop: 'y', at: [0, 1], values: [80, -80] }],\n 'depth-3': [{ prop: 'y', at: [0, 1], values: [140, -140] }],\n 'fade-window': [{ prop: 'opacity', at: [0, 0.15, 0.85, 1], values: [0, 1, 1, 0] }],\n 'rail-x': [{ prop: 'x', at: [0, 1], values: [0, -100], unit: '%' }],\n 'zoom-through': [{ prop: 'scale', at: [0, 1], values: [0.85, 1.1] }],\n 'unblur-in': [{ prop: 'blur', at: [0, 0.3], values: [10, 0] }],\n 'rise-in': [\n { prop: 'y', at: [0, 0.35], values: [70, 0] },\n { prop: 'opacity', at: [0, 0.3], values: [0, 1] },\n ],\n 'ghost-out': [\n { prop: 'opacity', at: [0.7, 1], values: [1, 0] },\n { prop: 'blur', at: [0.7, 1], values: [0, 8] },\n ],\n 'color-in': [{ prop: 'grayscale', at: [0, 0.45], values: [1, 0] }],\n 'sun-up': [{ prop: 'brightness', at: [0, 0.4], values: [0.35, 1] }],\n 'fade-to-mono': [\n { prop: 'grayscale', at: [0.6, 1], values: [0, 1] },\n { prop: 'saturate', at: [0.6, 1], values: [1, 0.6] },\n ],\n 'crash-zoom': [\n { prop: 'scale', at: [0, 0.25], values: [1.6, 1] },\n { prop: 'opacity', at: [0, 0.15], values: [0, 1] },\n ],\n 'tilt-reveal': [\n { prop: 'rotate-x', at: [0, 0.4], values: [35, 0] },\n { prop: 'opacity', at: [0, 0.3], values: [0, 1] },\n ],\n 'spin-in': [\n { prop: 'rotate', at: [0, 0.35], values: [-90, 0] },\n { prop: 'opacity', at: [0, 0.25], values: [0, 1] },\n ],\n breathe: [{ prop: 'scale', at: [0, 0.5, 1], values: [0.98, 1.03, 0.98] }],\n}\n\nconst isValidLane = (lane) => {\n if (!lane || typeof lane !== 'object' || !LANE_PROPS.includes(lane.prop)) {\n return false\n }\n if (!Array.isArray(lane.at) || !Array.isArray(lane.values)) {\n return false\n }\n if (lane.at.length < 2 || lane.at.length !== lane.values.length) {\n return false\n }\n const numbers = (list) => list.every((entry) => typeof entry === 'number' && isFinite(entry))\n if (!numbers(lane.at) || !numbers(lane.values)) {\n return false\n }\n for (let index = 1; index < lane.at.length; index++) {\n if (lane.at[index] < lane.at[index - 1]) {\n return false\n }\n }\n return lane.unit === undefined || lane.unit === 'px' || lane.unit === '%' || lane.unit === 'vw'\n}\n\n".concat(helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES.settledMomentForLanes, "\n\n").concat(helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES.activeChapterIndex, "\n\n").concat(helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES.scenePointList, "\n\n").concat(helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES.passedScenePoints, "\n\n").concat(helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES.scenePointRank, "\n\n").concat(helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES.unclipStickyAncestors, "\n\nconst parseScrollBind = (value) => {\n const raw = String(value || '').trim()\n if (!raw) {\n return []\n }\n if (LANE_PRESETS[raw]) {\n return LANE_PRESETS[raw].map((lane) => ({ ...lane }))\n }\n if (!raw.startsWith('[')) {\n return []\n }\n try {\n const parsed = JSON.parse(raw)\n return Array.isArray(parsed) ? parsed.filter(isValidLane) : []\n } catch (e) {\n return []\n }\n}\n\nconst laneValueAt = (lane, p) => {\n const at = lane.at\n const values = lane.values\n if (p <= at[0]) {\n return values[0]\n }\n if (p >= at[at.length - 1]) {\n return values[values.length - 1]\n }\n for (let index = 1; index < at.length; index++) {\n if (p <= at[index]) {\n const span = at[index] - at[index - 1]\n const local = span === 0 ? 1 : (p - at[index - 1]) / span\n return values[index - 1] + (values[index] - values[index - 1]) * local\n }\n }\n return values[values.length - 1]\n}\n\nconst FILTER_PROP_ORDER = ['blur', 'grayscale', 'saturate', 'brightness']\n\n// Motion lanes write the INDIVIDUAL transform properties (translate / scale /\n// rotate) and never the transform property itself: the browser composes them\n// with whatever the author put in transform (a translateX(-50%) centering, a\n// tilt), so the scene never clobbers the user's own layout. 3D lanes use the\n// axis form of rotate; the stage supplies the vanishing point. Mirrors the\n// canvas. (No backticks in this file's comments \u2014 it is a template literal.)\nconst applyLanesAt = (element, lanes, p) => {\n const filterByProp = {}\n let translateX\n let translateY\n let rotate\n let scale\n for (const lane of lanes) {\n const value = laneValueAt(lane, p)\n switch (lane.prop) {\n case 'x':\n translateX = value + (lane.unit || 'px')\n break\n case 'y':\n translateY = value + (lane.unit || 'px')\n break\n case 'scale':\n scale = String(value)\n break\n case 'rotate':\n rotate = rotate === undefined ? value + 'deg' : rotate\n break\n case 'rotate-x':\n rotate = 'x ' + value + 'deg'\n break\n case 'rotate-y':\n rotate = 'y ' + value + 'deg'\n break\n case 'opacity':\n element.style.opacity = String(value)\n // A faded-out element must not swallow clicks (stacked chapters: the\n // invisible top one would take every tap meant for the visible story).\n // Attribute + CSS rule, never inline pointer-events, so lanes cannot\n // overwrite a pointer-events the author set. Mirrors the editor.\n if (value <= 0.02) {\n element.setAttribute(HIDDEN_ATTR, '')\n } else {\n element.removeAttribute(HIDDEN_ATTR)\n }\n break\n case 'blur':\n filterByProp.blur = 'blur(' + value + 'px)'\n break\n case 'grayscale':\n filterByProp.grayscale = 'grayscale(' + value + ')'\n break\n case 'saturate':\n filterByProp.saturate = 'saturate(' + value + ')'\n break\n case 'brightness':\n filterByProp.brightness = 'brightness(' + value + ')'\n break\n case 'clip':\n element.style.clipPath = 'inset(0 ' + clampPercent(100 - value) + '% 0 0)'\n break\n case 'clip-y':\n element.style.clipPath = 'inset(0 0 ' + clampPercent(100 - value) + '% 0)'\n break\n case 'count':\n element.style.setProperty('--tq-count', String(Math.round(value)))\n if (!element.hasAttribute(COUNT_ATTR)) {\n element.setAttribute(COUNT_ATTR, '')\n }\n break\n }\n }\n if (translateX !== undefined || translateY !== undefined) {\n element.style.translate = (translateX || '0px') + ' ' + (translateY || '0px')\n }\n if (scale !== undefined) {\n element.style.scale = scale\n }\n if (rotate !== undefined) {\n element.style.rotate = rotate\n }\n const filterParts = FILTER_PROP_ORDER.map((prop) => filterByProp[prop]).filter(Boolean)\n if (filterParts.length > 0) {\n element.style.filter = filterParts.join(' ')\n }\n}\n\n// A scene set to keep the story for visitors who ask for less motion\n// (scene-reduced-motion \"story\"): the scroll still drives the scene, chapters\n// still come and go and every text still appears in turn, but nothing moves.\n// Slides, zooms, rotations and wipes are dropped, so each element stays where\n// the layout puts it; fades and filters still follow the scroll; a counting\n// number shows the figure it counts to. Mirrors the editor's lane contract.\nconst MOVEMENT_PROPS = ['x', 'y', 'scale', 'rotate', 'rotate-x', 'rotate-y', 'clip', 'clip-y']\n\nconst storyLanes = (lanes) =>\n lanes\n .filter((lane) => !MOVEMENT_PROPS.includes(lane.prop))\n .map((lane) => {\n if (lane.prop !== 'count') {\n return lane\n }\n const figure = lane.values[lane.values.length - 1]\n return { prop: 'count', at: [0, 1], values: [figure, figure] }\n })\n\n// What a moving lane painted, taken off again when the scene switches to the\n// story without movement while the page is open.\nconst clearMovement = (element, lanes) => {\n for (const lane of lanes) {\n if (lane.prop === 'x' || lane.prop === 'y') {\n element.style.translate = ''\n } else if (lane.prop === 'scale') {\n element.style.scale = ''\n } else if (lane.prop === 'rotate' || lane.prop === 'rotate-x' || lane.prop === 'rotate-y') {\n element.style.rotate = ''\n } else if (lane.prop === 'clip' || lane.prop === 'clip-y') {\n element.style.clipPath = ''\n }\n }\n}\n\n// A row wider than the stage that travelled sideways with the scroll (a\n// rail) would show only its first cards once the movement is dropped, so it\n// becomes a row the visitor swipes: every card stays reachable.\nconst SWIPE_ATTR = 'data-scene-swipe'\nconst letRowsSwipe = (bound, stage) => {\n if (!stage) {\n return\n }\n const stageWidth = stage.getBoundingClientRect().width\n for (const child of bound) {\n const travels = child.lanes.some((lane) => lane.prop === 'x')\n if (!travels || child.element.getBoundingClientRect().width <= stageWidth + 1) {\n continue\n }\n child.element.style.maxWidth = '100%'\n child.element.style.overflowX = 'auto'\n child.element.setAttribute(SWIPE_ATTR, '')\n }\n}\n\nconst collectBound = (track) => {\n const bound = []\n track.querySelectorAll('[' + SCROLL_BIND_ATTR + ']').forEach((element) => {\n const lanes = parseScrollBind(element.getAttribute(SCROLL_BIND_ATTR))\n if (lanes.length > 0) {\n bound.push({ element, lanes })\n }\n })\n return bound\n}\n\nconst normalizeSceneLength = (value) => {\n const match = /^(\\d{2,4})vh$/.exec(String(value || '').trim())\n if (!match) {\n return '300vh'\n }\n // Hard safety bound only \u2014 the editor owns the story-sized soft cap.\n return Math.min(4000, Math.max(100, Number(match[1]))) + 'vh'\n}"); };
|
|
22
|
+
exports.scrollSceneEngineSource = scrollSceneEngineSource;
|
|
23
|
+
//# sourceMappingURL=engine-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-source.js","sourceRoot":"","sources":["../../../src/scroll-scene/engine-source.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,uEAAwE;AAEjE,IAAM,uBAAuB,GAAG,cAAc,OAAA,6mHAiGnD,sDAA2B,CAAC,qBAAqB,iBAEjD,sDAA2B,CAAC,kBAAkB,iBAE9C,sDAA2B,CAAC,cAAc,iBAE1C,sDAA2B,CAAC,iBAAiB,iBAE7C,sDAA2B,CAAC,cAAc,iBAE1C,sDAA2B,CAAC,qBAAqB,u0NAyMjD,EApTmD,CAoTnD,CAAA;AApTW,QAAA,uBAAuB,2BAoTlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const SCROLL_SCENE_HELPER_SOURCES: {
|
|
2
|
+
settledMomentForLanes: string;
|
|
3
|
+
activeChapterIndex: string;
|
|
4
|
+
scenePointList: string;
|
|
5
|
+
passedScenePoints: string;
|
|
6
|
+
scenePointRank: string;
|
|
7
|
+
unclipStickyAncestors: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=helper-sources.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-sources.generated.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/helper-sources.generated.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,2BAA2B;;;;;;;CAavC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SCROLL_SCENE_HELPER_SOURCES = void 0;
|
|
4
|
+
// Generated by scripts/function-sources.js from moment.ts, chapter-index.ts, points.ts, unclip.ts. Do not edit:
|
|
5
|
+
// `node scripts/function-sources.js` rewrites it, and its drift test fails until it is current.
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
exports.SCROLL_SCENE_HELPER_SOURCES = {
|
|
9
|
+
settledMomentForLanes: 'function settledMomentForLanes(lanes) {\n var arrive = -Infinity;\n var leave = Infinity;\n var lastStop = -Infinity;\n var found = false;\n for (var _i = 0, lanes_1 = lanes; _i < lanes_1.length; _i++) {\n var lane = lanes_1[_i];\n if (lane.at.length < 3) {\n continue;\n }\n var settledAt = null;\n for (var index = 1; index < lane.values.length - 1; index++) {\n if (lane.values[index] === lane.values[index + 1] && lane.values[index] !== lane.values[0]) {\n settledAt = index;\n break;\n }\n }\n if (settledAt === null && lane.values[0] === lane.values[1]) {\n settledAt = 0;\n }\n if (settledAt === null) {\n continue;\n }\n found = true;\n arrive = Math.max(arrive, lane.at[settledAt]);\n lastStop = Math.max(lastStop, lane.at[lane.at.length - 1]);\n var settledValue = lane.values[settledAt];\n for (var index = settledAt + 1; index < lane.values.length; index++) {\n if (lane.values[index] !== settledValue) {\n leave = Math.min(leave, lane.at[index - 1]);\n break;\n }\n }\n }\n if (!found) {\n return null;\n }\n if (leave === Infinity) {\n leave = lastStop;\n }\n if (leave < arrive) {\n return null;\n }\n return Math.round(((arrive + leave) / 2) * 10000) / 10000;\n}',
|
|
10
|
+
activeChapterIndex: 'function activeChapterIndex(moments, progress) {\n var active = -1;\n var best = -Infinity;\n for (var index = 0; index < moments.length; index++) {\n var moment = moments[index];\n if (moment <= progress + 0.000001 && moment >= best) {\n best = moment;\n active = index;\n }\n }\n return active;\n}',
|
|
11
|
+
scenePointList: "function scenePointList() {\n return [\n { key: 'quarter', at: 0.25 },\n { key: 'half', at: 0.5 },\n { key: 'three-quarters', at: 0.75 },\n { key: 'end', at: 1 },\n ];\n}",
|
|
12
|
+
passedScenePoints: 'function passedScenePoints(from, to) {\n var passed = [];\n var points = scenePointList();\n for (var index = 0; index < points.length; index++) {\n var point = points[index];\n if (point.at > from + 0.000001 && point.at <= to + 0.000001) {\n passed.push(point.key);\n }\n }\n return passed;\n}',
|
|
13
|
+
scenePointRank: 'function scenePointRank(key) {\n var points = scenePointList();\n for (var index = 0; index < points.length; index++) {\n if (points[index].key === key) {\n return index + 1;\n }\n }\n return 0;\n}',
|
|
14
|
+
unclipStickyAncestors: "function unclipStickyAncestors(track, getStyle) {\n var unclipped = [];\n var element = track.parentElement;\n while (element && element !== element.ownerDocument.documentElement) {\n var style = getStyle(element);\n var both = style.overflow === 'hidden';\n var axes = [];\n if (both || style.overflowX === 'hidden') {\n axes.push('x');\n }\n if (both || style.overflowY === 'hidden') {\n axes.push('y');\n }\n if (axes.length > 0) {\n var host = element;\n for (var i = 0; i < axes.length; i++) {\n host.style.setProperty('overflow-' + axes[i], 'clip');\n }\n host.setAttribute('data-scene-unclipped', axes.join(''));\n unclipped.push(host.tagName.toLowerCase() +\n (host.className ? '.' + String(host.className).split(' ')[0] : ''));\n }\n element = element.parentElement;\n }\n return unclipped;\n}",
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=helper-sources.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-sources.generated.js","sourceRoot":"","sources":["../../../src/scroll-scene/helper-sources.generated.ts"],"names":[],"mappings":";;;AAAA,gHAAgH;AAChH,gGAAgG;AAChG,oBAAoB;AACpB,oBAAoB;AACP,QAAA,2BAA2B,GAAG;IACzC,qBAAqB,EACnB,i9CAAi9C;IACn9C,kBAAkB,EAChB,uWAAuW;IACzW,cAAc,EACZ,8MAA8M;IAChN,iBAAiB,EACf,uVAAuV;IACzV,cAAc,EACZ,4OAA4O;IAC9O,qBAAqB,EACnB,o+BAAo+B;CACv+B,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { settledMomentForLanes, MomentLane } from './moment';
|
|
2
|
+
export { activeChapterIndex } from './chapter-index';
|
|
3
|
+
export { passedScenePoints, scenePointList, scenePointRank } from './points';
|
|
4
|
+
export { unclipStickyAncestors } from './unclip';
|
|
5
|
+
export { SCROLL_SCENE_HELPER_SOURCES } from './helper-sources.generated';
|
|
6
|
+
export { scrollSceneEngineSource as engineSource } from './engine-source';
|
|
7
|
+
export { announcementsSource, restackBodySource, chapterHelpersSource, anchorNavigationBodySource, gentleSnapBodySource, } from './controller-source';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AACxE,OAAO,EAAE,uBAAuB,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gentleSnapBodySource = exports.anchorNavigationBodySource = exports.chapterHelpersSource = exports.restackBodySource = exports.announcementsSource = exports.engineSource = exports.SCROLL_SCENE_HELPER_SOURCES = exports.unclipStickyAncestors = exports.scenePointRank = exports.scenePointList = exports.passedScenePoints = exports.activeChapterIndex = exports.settledMomentForLanes = void 0;
|
|
4
|
+
var moment_1 = require("./moment");
|
|
5
|
+
Object.defineProperty(exports, "settledMomentForLanes", { enumerable: true, get: function () { return moment_1.settledMomentForLanes; } });
|
|
6
|
+
var chapter_index_1 = require("./chapter-index");
|
|
7
|
+
Object.defineProperty(exports, "activeChapterIndex", { enumerable: true, get: function () { return chapter_index_1.activeChapterIndex; } });
|
|
8
|
+
var points_1 = require("./points");
|
|
9
|
+
Object.defineProperty(exports, "passedScenePoints", { enumerable: true, get: function () { return points_1.passedScenePoints; } });
|
|
10
|
+
Object.defineProperty(exports, "scenePointList", { enumerable: true, get: function () { return points_1.scenePointList; } });
|
|
11
|
+
Object.defineProperty(exports, "scenePointRank", { enumerable: true, get: function () { return points_1.scenePointRank; } });
|
|
12
|
+
var unclip_1 = require("./unclip");
|
|
13
|
+
Object.defineProperty(exports, "unclipStickyAncestors", { enumerable: true, get: function () { return unclip_1.unclipStickyAncestors; } });
|
|
14
|
+
var helper_sources_generated_1 = require("./helper-sources.generated");
|
|
15
|
+
Object.defineProperty(exports, "SCROLL_SCENE_HELPER_SOURCES", { enumerable: true, get: function () { return helper_sources_generated_1.SCROLL_SCENE_HELPER_SOURCES; } });
|
|
16
|
+
var engine_source_1 = require("./engine-source");
|
|
17
|
+
Object.defineProperty(exports, "engineSource", { enumerable: true, get: function () { return engine_source_1.scrollSceneEngineSource; } });
|
|
18
|
+
var controller_source_1 = require("./controller-source");
|
|
19
|
+
Object.defineProperty(exports, "announcementsSource", { enumerable: true, get: function () { return controller_source_1.announcementsSource; } });
|
|
20
|
+
Object.defineProperty(exports, "restackBodySource", { enumerable: true, get: function () { return controller_source_1.restackBodySource; } });
|
|
21
|
+
Object.defineProperty(exports, "chapterHelpersSource", { enumerable: true, get: function () { return controller_source_1.chapterHelpersSource; } });
|
|
22
|
+
Object.defineProperty(exports, "anchorNavigationBodySource", { enumerable: true, get: function () { return controller_source_1.anchorNavigationBodySource; } });
|
|
23
|
+
Object.defineProperty(exports, "gentleSnapBodySource", { enumerable: true, get: function () { return controller_source_1.gentleSnapBodySource; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scroll-scene/index.ts"],"names":[],"mappings":";;;AAAA,mCAA4D;AAAnD,+GAAA,qBAAqB,OAAA;AAC9B,iDAAoD;AAA3C,mHAAA,kBAAkB,OAAA;AAC3B,mCAA4E;AAAnE,2GAAA,iBAAiB,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,wGAAA,cAAc,OAAA;AAC1D,mCAAgD;AAAvC,+GAAA,qBAAqB,OAAA;AAC9B,uEAAwE;AAA/D,uIAAA,2BAA2B,OAAA;AACpC,iDAAyE;AAAhE,6GAAA,uBAAuB,OAAgB;AAChD,yDAM4B;AAL1B,wHAAA,mBAAmB,OAAA;AACnB,sHAAA,iBAAiB,OAAA;AACjB,yHAAA,oBAAoB,OAAA;AACpB,+HAAA,0BAA0B,OAAA;AAC1B,yHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The progress where a chapter is fully ON STAGE — every lane has arrived
|
|
3
|
+
* and none has started leaving — the centre of that settled span, in the
|
|
4
|
+
* lanes' own (absolute) progress space. The gentle snap and anchor
|
|
5
|
+
* navigation aim here instead of the window's midpoint, which catches the
|
|
6
|
+
* last beat still rising (a half-visible line, a half-arrived card).
|
|
7
|
+
* Null when nothing settles (a chapter made only of through-motion, e.g. a
|
|
8
|
+
* crossing line — its best moment is the window's middle, the caller's
|
|
9
|
+
* fallback).
|
|
10
|
+
*
|
|
11
|
+
* MIRRORED VERBATIM from teleport-gui's chapter-window.ts (the editor draws
|
|
12
|
+
* the same moment on the timeline). Plain JS inside: this function's SOURCE
|
|
13
|
+
* is injected into the generated TqScrollScene runtime via toString(), so no
|
|
14
|
+
* TypeScript-only runtime constructs and no template literals.
|
|
15
|
+
*/
|
|
16
|
+
export interface MomentLane {
|
|
17
|
+
at: number[];
|
|
18
|
+
values: number[];
|
|
19
|
+
}
|
|
20
|
+
export declare function settledMomentForLanes(lanes: MomentLane[]): number | null;
|
|
21
|
+
//# sourceMappingURL=moment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moment.d.ts","sourceRoot":"","sources":["../../../src/scroll-scene/moment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,EAAE,CAAA;IACZ,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,IAAI,CA2CxE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.settledMomentForLanes = void 0;
|
|
4
|
+
function settledMomentForLanes(lanes) {
|
|
5
|
+
var arrive = -Infinity;
|
|
6
|
+
var leave = Infinity;
|
|
7
|
+
var lastStop = -Infinity;
|
|
8
|
+
var found = false;
|
|
9
|
+
for (var _i = 0, lanes_1 = lanes; _i < lanes_1.length; _i++) {
|
|
10
|
+
var lane = lanes_1[_i];
|
|
11
|
+
if (lane.at.length < 3) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
var settledAt = null;
|
|
15
|
+
for (var index = 1; index < lane.values.length - 1; index++) {
|
|
16
|
+
if (lane.values[index] === lane.values[index + 1] && lane.values[index] !== lane.values[0]) {
|
|
17
|
+
settledAt = index;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (settledAt === null && lane.values[0] === lane.values[1]) {
|
|
22
|
+
settledAt = 0;
|
|
23
|
+
}
|
|
24
|
+
if (settledAt === null) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
found = true;
|
|
28
|
+
arrive = Math.max(arrive, lane.at[settledAt]);
|
|
29
|
+
lastStop = Math.max(lastStop, lane.at[lane.at.length - 1]);
|
|
30
|
+
var settledValue = lane.values[settledAt];
|
|
31
|
+
for (var index = settledAt + 1; index < lane.values.length; index++) {
|
|
32
|
+
if (lane.values[index] !== settledValue) {
|
|
33
|
+
leave = Math.min(leave, lane.at[index - 1]);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!found) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (leave === Infinity) {
|
|
42
|
+
leave = lastStop;
|
|
43
|
+
}
|
|
44
|
+
if (leave < arrive) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return Math.round(((arrive + leave) / 2) * 10000) / 10000;
|
|
48
|
+
}
|
|
49
|
+
exports.settledMomentForLanes = settledMomentForLanes;
|
|
50
|
+
//# sourceMappingURL=moment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moment.js","sourceRoot":"","sources":["../../../src/scroll-scene/moment.ts"],"names":[],"mappings":";;;AAoBA,SAAgB,qBAAqB,CAAC,KAAmB;IACvD,IAAI,MAAM,GAAG,CAAC,QAAQ,CAAA;IACtB,IAAI,KAAK,GAAG,QAAQ,CAAA;IACpB,IAAI,QAAQ,GAAG,CAAC,QAAQ,CAAA;IACxB,IAAI,KAAK,GAAG,KAAK,CAAA;IACjB,K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