@bydiorama/motion 0.0.0-stage → 0.4.1
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/CREDITS.md +53 -0
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/catalog.json +4697 -0
- package/dist/npm/brief/brief.d.ts +28 -0
- package/dist/npm/brief/brief.js +159 -0
- package/dist/npm/brief/types.d.ts +75 -0
- package/dist/npm/brief/types.js +2 -0
- package/dist/npm/browser/motion.js +1039 -0
- package/dist/npm/browser/page.js +4821 -0
- package/dist/npm/browser/wizard.js +1511 -0
- package/dist/npm/build/design.d.ts +54 -0
- package/dist/npm/build/design.js +91 -0
- package/dist/npm/build/index.d.ts +39 -0
- package/dist/npm/build/index.js +66 -0
- package/dist/npm/build/iso.d.ts +41 -0
- package/dist/npm/build/iso.js +71 -0
- package/dist/npm/catalog.d.ts +24 -0
- package/dist/npm/catalog.js +23 -0
- package/dist/npm/cli/browser.d.ts +26 -0
- package/dist/npm/cli/browser.js +66 -0
- package/dist/npm/cli/capture.d.ts +26 -0
- package/dist/npm/cli/capture.js +94 -0
- package/dist/npm/cli/files.d.ts +14 -0
- package/dist/npm/cli/files.js +87 -0
- package/dist/npm/cli/frames.d.ts +27 -0
- package/dist/npm/cli/frames.js +125 -0
- package/dist/npm/cli/guard.d.ts +23 -0
- package/dist/npm/cli/guard.js +158 -0
- package/dist/npm/cli/library.d.ts +2 -0
- package/dist/npm/cli/library.js +55 -0
- package/dist/npm/cli/main.d.ts +17 -0
- package/dist/npm/cli/main.js +964 -0
- package/dist/npm/cli/motion.d.ts +2 -0
- package/dist/npm/cli/motion.js +6 -0
- package/dist/npm/cli/record.d.ts +36 -0
- package/dist/npm/cli/record.js +142 -0
- package/dist/npm/cli/review.d.ts +45 -0
- package/dist/npm/cli/review.js +139 -0
- package/dist/npm/cli/schema.d.ts +852 -0
- package/dist/npm/cli/schema.js +120 -0
- package/dist/npm/cli/server.d.ts +17 -0
- package/dist/npm/cli/server.js +135 -0
- package/dist/npm/core/ease.d.ts +39 -0
- package/dist/npm/core/ease.js +176 -0
- package/dist/npm/core/frame.d.ts +52 -0
- package/dist/npm/core/frame.js +60 -0
- package/dist/npm/core/shapes.d.ts +8 -0
- package/dist/npm/core/shapes.js +88 -0
- package/dist/npm/core/stagger.d.ts +19 -0
- package/dist/npm/core/stagger.js +77 -0
- package/dist/npm/core/tap.d.ts +19 -0
- package/dist/npm/core/tap.js +42 -0
- package/dist/npm/core/track.d.ts +4 -0
- package/dist/npm/core/track.js +23 -0
- package/dist/npm/dom/mount.d.ts +127 -0
- package/dist/npm/dom/mount.js +950 -0
- package/dist/npm/dom/page.d.ts +37 -0
- package/dist/npm/dom/page.js +77 -0
- package/dist/npm/dom/soundtrack.d.ts +13 -0
- package/dist/npm/dom/soundtrack.js +37 -0
- package/dist/npm/dom/stage.css.d.ts +1 -0
- package/dist/npm/dom/stage.css.js +44 -0
- package/dist/npm/dom/tokens.d.ts +10 -0
- package/dist/npm/dom/tokens.js +38 -0
- package/dist/npm/dom/ui-themes.css.d.ts +8 -0
- package/dist/npm/dom/ui-themes.css.js +9 -0
- package/dist/npm/film/beats.d.ts +64 -0
- package/dist/npm/film/beats.js +282 -0
- package/dist/npm/film/pace.d.ts +94 -0
- package/dist/npm/film/pace.js +396 -0
- package/dist/npm/film/resolve.d.ts +16 -0
- package/dist/npm/film/resolve.js +997 -0
- package/dist/npm/film/tempo.d.ts +19 -0
- package/dist/npm/film/tempo.js +34 -0
- package/dist/npm/film/tune.d.ts +17 -0
- package/dist/npm/film/tune.js +68 -0
- package/dist/npm/film/types.d.ts +416 -0
- package/dist/npm/film/types.js +16 -0
- package/dist/npm/index.d.ts +18 -0
- package/dist/npm/index.js +11 -0
- package/dist/npm/primitives/blur.d.ts +14 -0
- package/dist/npm/primitives/blur.js +59 -0
- package/dist/npm/primitives/canvas.d.ts +5 -0
- package/dist/npm/primitives/canvas.js +13 -0
- package/dist/npm/primitives/el/box.d.ts +2 -0
- package/dist/npm/primitives/el/box.js +24 -0
- package/dist/npm/primitives/el/frames.d.ts +15 -0
- package/dist/npm/primitives/el/frames.js +71 -0
- package/dist/npm/primitives/el/html.d.ts +2 -0
- package/dist/npm/primitives/el/html.js +14 -0
- package/dist/npm/primitives/el/image.d.ts +2 -0
- package/dist/npm/primitives/el/image.js +43 -0
- package/dist/npm/primitives/el/slot.d.ts +2 -0
- package/dist/npm/primitives/el/slot.js +25 -0
- package/dist/npm/primitives/el/text.d.ts +2 -0
- package/dist/npm/primitives/el/text.js +13 -0
- package/dist/npm/primitives/el/video.d.ts +6 -0
- package/dist/npm/primitives/el/video.js +179 -0
- package/dist/npm/primitives/fx/counter-roll.d.ts +2 -0
- package/dist/npm/primitives/fx/counter-roll.js +32 -0
- package/dist/npm/primitives/fx/depth-drift.d.ts +2 -0
- package/dist/npm/primitives/fx/depth-drift.js +44 -0
- package/dist/npm/primitives/fx/grid-ripple.d.ts +2 -0
- package/dist/npm/primitives/fx/grid-ripple.js +59 -0
- package/dist/npm/primitives/fx/odometer.d.ts +2 -0
- package/dist/npm/primitives/fx/odometer.js +80 -0
- package/dist/npm/primitives/fx/pan-across.d.ts +17 -0
- package/dist/npm/primitives/fx/pan-across.js +76 -0
- package/dist/npm/primitives/fx/path-draw.d.ts +2 -0
- package/dist/npm/primitives/fx/path-draw.js +105 -0
- package/dist/npm/primitives/fx/pin-drop.d.ts +2 -0
- package/dist/npm/primitives/fx/pin-drop.js +92 -0
- package/dist/npm/primitives/fx/shape-morph.d.ts +2 -0
- package/dist/npm/primitives/fx/shape-morph.js +65 -0
- package/dist/npm/primitives/fx/slow-push.d.ts +13 -0
- package/dist/npm/primitives/fx/slow-push.js +56 -0
- package/dist/npm/primitives/fx/stagger-fill.d.ts +2 -0
- package/dist/npm/primitives/fx/stagger-fill.js +33 -0
- package/dist/npm/primitives/index.d.ts +4 -0
- package/dist/npm/primitives/index.js +78 -0
- package/dist/npm/primitives/rig/browser-window.d.ts +2 -0
- package/dist/npm/primitives/rig/browser-window.js +142 -0
- package/dist/npm/primitives/rig/camera.d.ts +36 -0
- package/dist/npm/primitives/rig/camera.js +81 -0
- package/dist/npm/primitives/rig/footage-plane.d.ts +27 -0
- package/dist/npm/primitives/rig/footage-plane.js +257 -0
- package/dist/npm/primitives/rig/layer-stack.d.ts +39 -0
- package/dist/npm/primitives/rig/layer-stack.js +276 -0
- package/dist/npm/primitives/rig/orbit-ring.d.ts +2 -0
- package/dist/npm/primitives/rig/orbit-ring.js +59 -0
- package/dist/npm/primitives/rig/tab-stack.d.ts +9 -0
- package/dist/npm/primitives/rig/tab-stack.js +143 -0
- package/dist/npm/primitives/scene/bar-chart.d.ts +2 -0
- package/dist/npm/primitives/scene/bar-chart.js +83 -0
- package/dist/npm/primitives/scene/bento-grid.d.ts +49 -0
- package/dist/npm/primitives/scene/bento-grid.js +293 -0
- package/dist/npm/primitives/scene/grid-wall.d.ts +18 -0
- package/dist/npm/primitives/scene/grid-wall.js +110 -0
- package/dist/npm/primitives/scene/line-chart.d.ts +2 -0
- package/dist/npm/primitives/scene/line-chart.js +121 -0
- package/dist/npm/primitives/scene/logo-reveal.d.ts +2 -0
- package/dist/npm/primitives/scene/logo-reveal.js +117 -0
- package/dist/npm/primitives/scene/marquee-wall.d.ts +2 -0
- package/dist/npm/primitives/scene/marquee-wall.js +82 -0
- package/dist/npm/primitives/scene/post-carousel.d.ts +16 -0
- package/dist/npm/primitives/scene/post-carousel.js +195 -0
- package/dist/npm/primitives/scene/strip-cycle.d.ts +49 -0
- package/dist/npm/primitives/scene/strip-cycle.js +237 -0
- package/dist/npm/primitives/split.d.ts +34 -0
- package/dist/npm/primitives/split.js +105 -0
- package/dist/npm/primitives/texture/beat-field.d.ts +13 -0
- package/dist/npm/primitives/texture/beat-field.js +113 -0
- package/dist/npm/primitives/texture/gradient-drift.d.ts +2 -0
- package/dist/npm/primitives/texture/gradient-drift.js +56 -0
- package/dist/npm/primitives/texture/grain.d.ts +2 -0
- package/dist/npm/primitives/texture/grain.js +54 -0
- package/dist/npm/primitives/texture/halftone-field.d.ts +2 -0
- package/dist/npm/primitives/texture/halftone-field.js +36 -0
- package/dist/npm/primitives/texture/signal-field.d.ts +4 -0
- package/dist/npm/primitives/texture/signal-field.js +107 -0
- package/dist/npm/primitives/texture/vignette.d.ts +2 -0
- package/dist/npm/primitives/texture/vignette.js +23 -0
- package/dist/npm/primitives/transition/band-sweep.d.ts +22 -0
- package/dist/npm/primitives/transition/band-sweep.js +111 -0
- package/dist/npm/primitives/transition/beat-cut.d.ts +2 -0
- package/dist/npm/primitives/transition/beat-cut.js +10 -0
- package/dist/npm/primitives/transition/blur-dissolve.d.ts +2 -0
- package/dist/npm/primitives/transition/blur-dissolve.js +28 -0
- package/dist/npm/primitives/transition/camera-travel.d.ts +2 -0
- package/dist/npm/primitives/transition/camera-travel.js +69 -0
- package/dist/npm/primitives/transition/cover-reveal.d.ts +2 -0
- package/dist/npm/primitives/transition/cover-reveal.js +52 -0
- package/dist/npm/primitives/transition/curtain.d.ts +2 -0
- package/dist/npm/primitives/transition/curtain.js +40 -0
- package/dist/npm/primitives/transition/dive-in.d.ts +2 -0
- package/dist/npm/primitives/transition/dive-in.js +52 -0
- package/dist/npm/primitives/transition/fly-past.d.ts +2 -0
- package/dist/npm/primitives/transition/fly-past.js +87 -0
- package/dist/npm/primitives/transition/iris.d.ts +2 -0
- package/dist/npm/primitives/transition/iris.js +38 -0
- package/dist/npm/primitives/transition/overlay.d.ts +4 -0
- package/dist/npm/primitives/transition/overlay.js +24 -0
- package/dist/npm/primitives/transition/push.d.ts +2 -0
- package/dist/npm/primitives/transition/push.js +35 -0
- package/dist/npm/primitives/transition/signal-wipe.d.ts +2 -0
- package/dist/npm/primitives/transition/signal-wipe.js +67 -0
- package/dist/npm/primitives/transition/slant-wipe.d.ts +2 -0
- package/dist/npm/primitives/transition/slant-wipe.js +30 -0
- package/dist/npm/primitives/transition/stack-over.d.ts +2 -0
- package/dist/npm/primitives/transition/stack-over.js +38 -0
- package/dist/npm/primitives/transition/step-wipe.d.ts +2 -0
- package/dist/npm/primitives/transition/step-wipe.js +29 -0
- package/dist/npm/primitives/transition/strip-wipe.d.ts +40 -0
- package/dist/npm/primitives/transition/strip-wipe.js +121 -0
- package/dist/npm/primitives/transition/whip-pan.d.ts +2 -0
- package/dist/npm/primitives/transition/whip-pan.js +45 -0
- package/dist/npm/primitives/type/block-reveal.d.ts +2 -0
- package/dist/npm/primitives/type/block-reveal.js +61 -0
- package/dist/npm/primitives/type/char-cascade.d.ts +2 -0
- package/dist/npm/primitives/type/char-cascade.js +45 -0
- package/dist/npm/primitives/type/echo.d.ts +2 -0
- package/dist/npm/primitives/type/echo.js +57 -0
- package/dist/npm/primitives/type/fill-text.d.ts +14 -0
- package/dist/npm/primitives/type/fill-text.js +82 -0
- package/dist/npm/primitives/type/mask-reveal.d.ts +2 -0
- package/dist/npm/primitives/type/mask-reveal.js +58 -0
- package/dist/npm/primitives/type/scramble.d.ts +2 -0
- package/dist/npm/primitives/type/scramble.js +34 -0
- package/dist/npm/primitives/type/scribble-highlight.d.ts +2 -0
- package/dist/npm/primitives/type/scribble-highlight.js +84 -0
- package/dist/npm/primitives/type/shimmer.d.ts +2 -0
- package/dist/npm/primitives/type/shimmer.js +35 -0
- package/dist/npm/primitives/type/tracking-in.d.ts +2 -0
- package/dist/npm/primitives/type/tracking-in.js +37 -0
- package/dist/npm/primitives/type/typed-title.d.ts +2 -0
- package/dist/npm/primitives/type/typed-title.js +33 -0
- package/dist/npm/primitives/type/word-build.d.ts +2 -0
- package/dist/npm/primitives/type/word-build.js +44 -0
- package/dist/npm/primitives/type/word-roller.d.ts +2 -0
- package/dist/npm/primitives/type/word-roller.js +80 -0
- package/dist/npm/primitives/types.d.ts +183 -0
- package/dist/npm/primitives/types.js +5 -0
- package/dist/npm/primitives/ui/cursor-click.d.ts +4 -0
- package/dist/npm/primitives/ui/cursor-click.js +68 -0
- package/dist/npm/primitives/ui/page-scroll.d.ts +17 -0
- package/dist/npm/primitives/ui/page-scroll.js +98 -0
- package/dist/npm/review/fft.d.ts +4 -0
- package/dist/npm/review/fft.js +71 -0
- package/dist/npm/review/measure.d.ts +170 -0
- package/dist/npm/review/measure.js +577 -0
- package/dist/npm/tokens.d.ts +50 -0
- package/dist/npm/tokens.js +49 -0
- package/dist/npm/version.d.ts +1 -0
- package/dist/npm/version.js +1 -0
- package/examples/builder.film.mjs +18 -0
- package/films/feature-announcement.film.json +70 -0
- package/library/narratives/app-demo.md +64 -0
- package/library/narratives/brand-identity.md +78 -0
- package/library/narratives/capability-through-type.md +53 -0
- package/library/narratives/data-story.md +59 -0
- package/library/narratives/explainer.md +64 -0
- package/library/narratives/feature-announcement.md +68 -0
- package/library/narratives/infinite-loop.md +28 -0
- package/library/narratives/platform-launch.md +81 -0
- package/library/narratives/social-teaser.md +45 -0
- package/library/narratives/title-sequence.md +55 -0
- package/library/narratives/website-launch.md +65 -0
- package/library/primitives/fx/card-arrangements.md +26 -0
- package/library/primitives/fx/counter-roll.md +27 -0
- package/library/primitives/fx/depth-drift.md +32 -0
- package/library/primitives/fx/grid-ripple.md +58 -0
- package/library/primitives/fx/letter-interleave.md +26 -0
- package/library/primitives/fx/marquee-highlight.md +27 -0
- package/library/primitives/fx/mosaic-fill.md +23 -0
- package/library/primitives/fx/odometer.md +44 -0
- package/library/primitives/fx/pan-across.md +63 -0
- package/library/primitives/fx/path-draw.md +54 -0
- package/library/primitives/fx/pin-drop.md +51 -0
- package/library/primitives/fx/radial-burst.md +33 -0
- package/library/primitives/fx/shape-morph.md +45 -0
- package/library/primitives/fx/slow-push.md +63 -0
- package/library/primitives/fx/stagger-fill.md +28 -0
- package/library/primitives/rig/browser-window.md +113 -0
- package/library/primitives/rig/flip-ticker.md +26 -0
- package/library/primitives/rig/footage-plane.md +90 -0
- package/library/primitives/rig/layer-stack.md +168 -0
- package/library/primitives/rig/orbit-ring.md +43 -0
- package/library/primitives/rig/rolodex.md +31 -0
- package/library/primitives/rig/tab-stack.md +116 -0
- package/library/primitives/rig/tumbling-object.md +27 -0
- package/library/primitives/scene/bar-chart.md +49 -0
- package/library/primitives/scene/bento-grid.md +74 -0
- package/library/primitives/scene/end-card.md +28 -0
- package/library/primitives/scene/grid-wall.md +61 -0
- package/library/primitives/scene/hero-object.md +33 -0
- package/library/primitives/scene/kinetic-headline.md +34 -0
- package/library/primitives/scene/line-chart.md +47 -0
- package/library/primitives/scene/logo-reveal.md +53 -0
- package/library/primitives/scene/marquee-wall.md +33 -0
- package/library/primitives/scene/mosaic.md +28 -0
- package/library/primitives/scene/post-carousel.md +68 -0
- package/library/primitives/scene/specimen-grid.md +28 -0
- package/library/primitives/scene/stat-with-evidence.md +34 -0
- package/library/primitives/scene/strip-cycle.md +122 -0
- package/library/primitives/scene/zoomed-ui.md +29 -0
- package/library/primitives/texture/ascii.md +22 -0
- package/library/primitives/texture/beat-field.md +85 -0
- package/library/primitives/texture/depth-fade.md +23 -0
- package/library/primitives/texture/dither.md +27 -0
- package/library/primitives/texture/gradient-drift.md +50 -0
- package/library/primitives/texture/grain.md +39 -0
- package/library/primitives/texture/halftone-field.md +26 -0
- package/library/primitives/texture/signal-field.md +61 -0
- package/library/primitives/texture/vignette.md +53 -0
- package/library/primitives/transition/band-sweep.md +63 -0
- package/library/primitives/transition/beat-cut.md +27 -0
- package/library/primitives/transition/blur-dissolve.md +36 -0
- package/library/primitives/transition/camera-travel.md +57 -0
- package/library/primitives/transition/collapse-to-anchor.md +27 -0
- package/library/primitives/transition/cover-reveal.md +47 -0
- package/library/primitives/transition/curtain.md +42 -0
- package/library/primitives/transition/dive-in.md +51 -0
- package/library/primitives/transition/fly-past.md +51 -0
- package/library/primitives/transition/iris.md +49 -0
- package/library/primitives/transition/layout-locked-swap.md +28 -0
- package/library/primitives/transition/light-dark-flip.md +27 -0
- package/library/primitives/transition/push.md +47 -0
- package/library/primitives/transition/signal-wipe.md +52 -0
- package/library/primitives/transition/slant-wipe.md +44 -0
- package/library/primitives/transition/stack-over.md +51 -0
- package/library/primitives/transition/step-wipe.md +32 -0
- package/library/primitives/transition/strip-wipe.md +80 -0
- package/library/primitives/transition/torn-edge.md +26 -0
- package/library/primitives/transition/whip-pan.md +47 -0
- package/library/primitives/transition/zoom-through-letter.md +27 -0
- package/library/primitives/type/accent-number.md +22 -0
- package/library/primitives/type/block-reveal.md +41 -0
- package/library/primitives/type/char-cascade.md +65 -0
- package/library/primitives/type/echo.md +44 -0
- package/library/primitives/type/fill-text.md +63 -0
- package/library/primitives/type/focus-blur.md +22 -0
- package/library/primitives/type/inline-chips.md +27 -0
- package/library/primitives/type/mask-reveal.md +65 -0
- package/library/primitives/type/parting.md +23 -0
- package/library/primitives/type/per-word-restyle.md +28 -0
- package/library/primitives/type/scramble.md +26 -0
- package/library/primitives/type/scribble-highlight.md +47 -0
- package/library/primitives/type/shimmer.md +39 -0
- package/library/primitives/type/split-flap.md +26 -0
- package/library/primitives/type/style-multiply.md +23 -0
- package/library/primitives/type/tracking-in.md +40 -0
- package/library/primitives/type/typed-title.md +27 -0
- package/library/primitives/type/word-build.md +37 -0
- package/library/primitives/type/word-roller.md +52 -0
- package/library/primitives/type/writing-ticker.md +27 -0
- package/library/primitives/ui/collab-cursors.md +27 -0
- package/library/primitives/ui/cursor-click.md +61 -0
- package/library/primitives/ui/page-scroll.md +58 -0
- package/library/primitives/ui/prompt-typing.md +29 -0
- package/library/primitives/ui/streamed-result.md +23 -0
- package/library/primitives/ui/tour-hold.md +27 -0
- package/library/styles/brand-system.md +49 -0
- package/library/styles/clean-explainer.md +42 -0
- package/library/styles/dark-showcase.md +48 -0
- package/library/styles/editorial-type.md +37 -0
- package/library/styles/kinetic-poster.md +54 -0
- package/library/styles/product-ui.md +44 -0
- package/library/styles/studio-loop.md +41 -0
- package/library.json +1467 -0
- package/package.json +64 -4
- package/schema/film.schema.json +1316 -0
- package/showcase/vendor/DIALKIT-LICENSE +21 -0
- package/src/studio/theme/fonts/OFL.txt +94 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// scene/logo-reveal. See library/primitives/scene/logo-reveal.md.
|
|
2
|
+
import { progress } from "../../core/ease.js";
|
|
3
|
+
import { pointsPath, shapePoints } from "../../core/shapes.js";
|
|
4
|
+
import { num, str } from "../types.js";
|
|
5
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
6
|
+
const timing = (p, hasName, hasTag) => {
|
|
7
|
+
const arrive = num(p.arrive), slide = hasName ? num(p.slide) : 0;
|
|
8
|
+
const nameAt = arrive + 0.15;
|
|
9
|
+
const tagAt = nameAt + slide * 0.7;
|
|
10
|
+
return { arrive, slide, nameAt, tagAt, end: hasTag ? tagAt + 0.7 : nameAt + slide };
|
|
11
|
+
};
|
|
12
|
+
export const logoReveal = {
|
|
13
|
+
slug: 'scene/logo-reveal',
|
|
14
|
+
summary: 'The mark lands, then moves aside as the name slides out from behind it.',
|
|
15
|
+
props: {
|
|
16
|
+
name: { type: 'string', default: '', label: 'Wordmark text. Left out, the mark lands alone' },
|
|
17
|
+
tagline: { type: 'string', default: '', label: 'One short line under the lockup' },
|
|
18
|
+
mark_path: { type: 'string', default: '', label: 'SVG path data of the mark. Left out, a shape is used' },
|
|
19
|
+
mark_viewbox: { type: 'string', default: '0 0 100 100', label: 'viewBox of mark_path' },
|
|
20
|
+
mark_shape: { type: 'string', default: 'squircle', label: 'Shape used when there is no mark_path' },
|
|
21
|
+
},
|
|
22
|
+
params: {
|
|
23
|
+
mode: { type: 'choice', default: 'pop', options: ['pop', 'draw', 'iris'], label: 'How the mark arrives' },
|
|
24
|
+
arrive: { type: 'number', default: 0.8, min: 0.5, max: 1.6, step: 0.05, unit: 's', label: 'Time for the mark to land' },
|
|
25
|
+
slide: { type: 'number', default: 0.8, min: 0.5, max: 1.2, step: 0.05, unit: 's', label: 'Time for the name to slide out' },
|
|
26
|
+
mark_size: { type: 'number', default: 1.1, min: 0.6, max: 2, step: 0.05, unit: 'em', label: 'Mark height, relative to the name' },
|
|
27
|
+
gap: { type: 'number', default: 0.35, min: 0.1, max: 1, step: 0.05, unit: 'em', label: 'Gap between mark and name' },
|
|
28
|
+
},
|
|
29
|
+
duration: (props, p) => timing(p, !!str(props.name), !!str(props.tagline)).end,
|
|
30
|
+
build(el, props, p, ctx) {
|
|
31
|
+
const doc = el.ownerDocument;
|
|
32
|
+
const name = str(props.name), tagline = str(props.tagline), mode = str(p.mode);
|
|
33
|
+
const T = timing(p, !!name, !!tagline);
|
|
34
|
+
el.style.cssText += ';display:flex;flex-direction:column;align-items:center';
|
|
35
|
+
const lockup = doc.createElement('div');
|
|
36
|
+
lockup.style.cssText = `display:flex;align-items:center;gap:${num(p.gap)}em;white-space:nowrap`;
|
|
37
|
+
// The mark: a given path, or a shape from the library's set.
|
|
38
|
+
const mh = num(p.mark_size);
|
|
39
|
+
const svg = doc.createElementNS(SVG, 'svg');
|
|
40
|
+
const own = str(props.mark_path);
|
|
41
|
+
svg.setAttribute('viewBox', own ? str(props.mark_viewbox, '0 0 100 100') : '-1 -1 2 2');
|
|
42
|
+
svg.style.cssText = `display:block;height:${mh}em;width:${mh}em;overflow:visible;position:relative;z-index:1;flex:none`;
|
|
43
|
+
const mark = doc.createElementNS(SVG, 'path');
|
|
44
|
+
mark.setAttribute('d', own || pointsPath(shapePoints(str(props.mark_shape, 'squircle'), 160, ctx.seed), 0, 0, 1));
|
|
45
|
+
mark.setAttribute('fill', 'var(--m-bg-accent)');
|
|
46
|
+
mark.setAttribute('pathLength', '1');
|
|
47
|
+
mark.setAttribute('stroke-dasharray', '1 1');
|
|
48
|
+
mark.setAttribute('stroke', 'var(--m-bg-accent)');
|
|
49
|
+
mark.setAttribute('stroke-width', own ? '2' : '0.05');
|
|
50
|
+
mark.setAttribute('vector-effect', 'non-scaling-stroke');
|
|
51
|
+
svg.appendChild(mark);
|
|
52
|
+
lockup.appendChild(svg);
|
|
53
|
+
let word, wordBox;
|
|
54
|
+
if (name) {
|
|
55
|
+
wordBox = doc.createElement('span');
|
|
56
|
+
wordBox.style.cssText = 'display:block;overflow:hidden;padding:0.12em 0.04em;margin:-0.12em -0.04em';
|
|
57
|
+
word = doc.createElement('span');
|
|
58
|
+
word.textContent = name;
|
|
59
|
+
word.style.cssText = 'display:block';
|
|
60
|
+
wordBox.appendChild(word);
|
|
61
|
+
lockup.appendChild(wordBox);
|
|
62
|
+
}
|
|
63
|
+
el.appendChild(lockup);
|
|
64
|
+
let tag;
|
|
65
|
+
if (tagline) {
|
|
66
|
+
tag = doc.createElement('div');
|
|
67
|
+
tag.textContent = tagline;
|
|
68
|
+
tag.style.cssText = 'font-size:0.32em;font-weight:450;letter-spacing:0.01em;color:var(--m-text-muted);margin-top:0.9em';
|
|
69
|
+
el.appendChild(tag);
|
|
70
|
+
}
|
|
71
|
+
// How far the mark sits right of its final place while it lands alone, in px.
|
|
72
|
+
const shift = word ? (lockup.offsetWidth - svg.getBoundingClientRect().width / scaleOf(el)) / 2 : 0;
|
|
73
|
+
const pop = ctx.ease({ spring: { duration: 0.55, bounce: 0.32 } }), glide = ctx.ease('quint.inOut'), out = ctx.ease('expressive.out');
|
|
74
|
+
return {
|
|
75
|
+
seek(t) {
|
|
76
|
+
const a = progress(t, 0, T.arrive, mode === 'pop' ? pop : out);
|
|
77
|
+
if (mode === 'pop') {
|
|
78
|
+
svg.style.transform = `scale(${Math.max(0, a).toFixed(4)}) rotate(${((1 - a) * -30).toFixed(3)}deg)`;
|
|
79
|
+
mark.setAttribute('stroke-dashoffset', '0');
|
|
80
|
+
mark.setAttribute('fill-opacity', '1');
|
|
81
|
+
}
|
|
82
|
+
else if (mode === 'draw') {
|
|
83
|
+
const d = progress(t, 0, T.arrive * 0.8, glide), f = progress(t, T.arrive * 0.65, T.arrive * 0.35, out);
|
|
84
|
+
mark.setAttribute('stroke-dashoffset', (1 - d).toFixed(4));
|
|
85
|
+
mark.setAttribute('fill-opacity', f.toFixed(3));
|
|
86
|
+
svg.style.transform = '';
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// iris: the mark opens from a point at its centre
|
|
90
|
+
svg.style.clipPath = a >= 1 ? '' : `circle(${(a * 75).toFixed(3)}% at 50% 50%)`;
|
|
91
|
+
svg.style.transform = `scale(${(1.25 - 0.25 * a).toFixed(4)})`;
|
|
92
|
+
mark.setAttribute('stroke-dashoffset', '0');
|
|
93
|
+
}
|
|
94
|
+
const s = progress(t, T.nameAt, T.slide, glide);
|
|
95
|
+
const markX = shift * (1 - s);
|
|
96
|
+
lockup.style.transform = markX === 0 ? '' : `translateX(${markX.toFixed(2)}px)`;
|
|
97
|
+
if (word && wordBox) {
|
|
98
|
+
// The name comes out from behind the mark: it travels with a clip at its left edge.
|
|
99
|
+
const nk = progress(t, T.nameAt, T.slide, out);
|
|
100
|
+
word.style.transform = nk >= 1 ? '' : `translateX(${(-(1 - nk) * 105).toFixed(3)}%)`;
|
|
101
|
+
wordBox.style.visibility = t < T.nameAt ? 'hidden' : 'inherit';
|
|
102
|
+
}
|
|
103
|
+
if (tag) {
|
|
104
|
+
const k = progress(t, T.tagAt, 0.7, out);
|
|
105
|
+
tag.style.opacity = k.toFixed(3);
|
|
106
|
+
tag.style.transform = k >= 1 ? '' : `translateY(${((1 - k) * 0.6).toFixed(3)}em)`;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
function scaleOf(el) {
|
|
113
|
+
const stage = el.closest('.m-stage');
|
|
114
|
+
if (!stage || !stage.offsetWidth)
|
|
115
|
+
return 1;
|
|
116
|
+
return stage.getBoundingClientRect().width / stage.offsetWidth;
|
|
117
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// scene/marquee-wall, with fx/marquee-highlight for its emphasised item.
|
|
2
|
+
// See library/primitives/scene/marquee-wall.md and fx/marquee-highlight.md.
|
|
3
|
+
import { progress } from "../../core/ease.js";
|
|
4
|
+
import { list, num, str } from "../types.js";
|
|
5
|
+
const RATE = [1, 1.24, 0.6, 1.1, 0.9, 1.3]; // rows drift at slightly different speeds
|
|
6
|
+
const OFFSET = [0.1, 0.5, 0.92, 0.3, 0.7, 0.2];
|
|
7
|
+
export const marqueeWall = {
|
|
8
|
+
slug: 'scene/marquee-wall',
|
|
9
|
+
summary: 'Rows of chips or logos scrolling sideways.',
|
|
10
|
+
props: {
|
|
11
|
+
items: { type: 'string[]', required: true, label: 'Chip labels' },
|
|
12
|
+
highlight: { type: 'string', default: '', label: 'One label to emphasise while the others dim' },
|
|
13
|
+
},
|
|
14
|
+
params: {
|
|
15
|
+
rows: { type: 'number', default: 5, min: 4, max: 6, step: 1, unit: 'rows', label: 'Rows' },
|
|
16
|
+
speed: { type: 'number', default: 60, min: 30, max: 120, step: 5, unit: 'px/s', label: 'Scroll speed' },
|
|
17
|
+
dim_opacity: { type: 'number', default: 0.5, min: 0.4, max: 0.6, step: 0.01, unit: 'ratio', label: 'Opacity of the other items once one is emphasised', from: 'fx/marquee-highlight' },
|
|
18
|
+
highlight_at: { type: 'number', default: 1.5, min: 0, max: 10, step: 0.1, unit: 's', label: 'When the emphasis starts' },
|
|
19
|
+
},
|
|
20
|
+
// Ambient: it has no end of its own and runs for as long as its scene.
|
|
21
|
+
duration: () => 0,
|
|
22
|
+
build(el, props, p, ctx) {
|
|
23
|
+
const items = list(props.items), rows = Math.max(1, Math.round(num(p.rows))), speed = num(p.speed);
|
|
24
|
+
const highlight = str(props.highlight);
|
|
25
|
+
el.style.cssText += `;width:${ctx.size[0]}px;display:flex;flex-direction:column;gap:0.55em;overflow:hidden`;
|
|
26
|
+
const tracks = Array.from({ length: rows }, (_, r) => {
|
|
27
|
+
const row = items.filter((_, i) => i % rows === r);
|
|
28
|
+
const mine = row.length ? row : items;
|
|
29
|
+
const track = document.createElement('div');
|
|
30
|
+
track.style.cssText = 'display:flex;width:max-content;will-change:transform';
|
|
31
|
+
const fill = (host) => mine.forEach((label) => {
|
|
32
|
+
const c = document.createElement('span');
|
|
33
|
+
c.textContent = label;
|
|
34
|
+
c.style.cssText = 'position:relative;flex:none;margin-right:0.5em;padding:0.45em 0.9em;border-radius:999px;white-space:nowrap;background:var(--m-bg-surface)';
|
|
35
|
+
if (label === highlight) {
|
|
36
|
+
// The accent face sits on top and fades in with --k; nothing changes size, so rows never jump.
|
|
37
|
+
const face = document.createElement('span');
|
|
38
|
+
face.textContent = label;
|
|
39
|
+
face.setAttribute('aria-hidden', 'true');
|
|
40
|
+
face.style.cssText = 'position:absolute;inset:0;display:grid;place-items:center;border-radius:inherit;background:var(--m-bg-accent);color:var(--m-text-on-accent);opacity:var(--k, 0)';
|
|
41
|
+
c.appendChild(face);
|
|
42
|
+
c.style.transform = 'scale(calc(1 + 0.08 * var(--k, 0)))';
|
|
43
|
+
c.style.zIndex = '1';
|
|
44
|
+
}
|
|
45
|
+
else
|
|
46
|
+
c.style.opacity = 'calc(1 - var(--dim, 0) * var(--k, 0))';
|
|
47
|
+
host.appendChild(c);
|
|
48
|
+
});
|
|
49
|
+
// One set is measured, then repeated until it covers the stage twice over,
|
|
50
|
+
// so the row can wrap without a gap.
|
|
51
|
+
const unit = document.createElement('div');
|
|
52
|
+
unit.style.cssText = 'display:flex;flex:none';
|
|
53
|
+
fill(unit);
|
|
54
|
+
track.appendChild(unit);
|
|
55
|
+
el.appendChild(track);
|
|
56
|
+
const width = Math.max(1, unit.getBoundingClientRect().width / stageScale(el));
|
|
57
|
+
const copies = Math.ceil(ctx.size[0] / width) + 1;
|
|
58
|
+
for (let i = 0; i < copies; i++)
|
|
59
|
+
track.appendChild(unit.cloneNode(true));
|
|
60
|
+
return { track, width, dir: r % 2 ? -1 : 1, rate: RATE[r % RATE.length], off: OFFSET[r % OFFSET.length] };
|
|
61
|
+
});
|
|
62
|
+
const ease = ctx.ease(ctx.tokens.ease_move), at = num(p.highlight_at), fade = ctx.tokens.duration.slow;
|
|
63
|
+
el.style.setProperty('--dim', String(highlight ? 1 - num(p.dim_opacity) : 0));
|
|
64
|
+
return {
|
|
65
|
+
seek(t) {
|
|
66
|
+
el.style.setProperty('--k', String(highlight ? progress(t, at, fade, ease) : 0));
|
|
67
|
+
for (const r of tracks) {
|
|
68
|
+
const travelled = (t * speed * r.rate + r.off * r.width) % r.width;
|
|
69
|
+
r.track.style.transform = `translateX(${-(r.dir > 0 ? travelled : r.width - travelled)}px)`;
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
/** The stage is drawn scaled to fit its container; measurements must be undone by that scale. */
|
|
76
|
+
function stageScale(el) {
|
|
77
|
+
const stage = el.closest('.m-stage');
|
|
78
|
+
if (!stage)
|
|
79
|
+
return 1;
|
|
80
|
+
const w = stage.getBoundingClientRect().width;
|
|
81
|
+
return w > 0 && stage.offsetWidth > 0 ? w / stage.offsetWidth : 1;
|
|
82
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Primitive } from '../types.ts';
|
|
2
|
+
export declare const RATIOS: readonly ["4:5", "1:1", "9:16", "3:4", "16:9"];
|
|
3
|
+
/** A slide's size on a W×H stage: `width` of it, or smaller so the whole post fits 92% of its height. */
|
|
4
|
+
export declare function slideSize(p: Record<string, unknown>, W: number, H: number): {
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Where the row stands at t: 0 is the first slide in front, 1 the second, and
|
|
10
|
+
* so on, easing between them. A loop turns on from the last slide to the first,
|
|
11
|
+
* reaching n (= 0 again) at the end of its last step.
|
|
12
|
+
*/
|
|
13
|
+
export declare function rowAt(t: number, n: number, hold: number, turn: number, loop: boolean, ease?: (x: number) => number): number;
|
|
14
|
+
/** Slide i's place relative to the front at row position c: 0 in front, 1 beside on the right, −1 on the left. */
|
|
15
|
+
export declare function placeOf(i: number, c: number, n: number, loop: boolean): number;
|
|
16
|
+
export declare const postCarousel: Primitive;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// scene/post-carousel. See library/primitives/scene/post-carousel.md.
|
|
2
|
+
//
|
|
3
|
+
// A run of slides shown one at a time, as a social post or as bare posters.
|
|
4
|
+
// The slides stand side by side in one world: the one in front faces the
|
|
5
|
+
// camera, its neighbours stand beside it turned away, hinged on the edge
|
|
6
|
+
// nearest the frame, so they show as narrow strips. Each step, the row turns:
|
|
7
|
+
// the front slide swings out to one side as the next swings in from the other.
|
|
8
|
+
// With chrome, a post's header and footer stay put above and below while the
|
|
9
|
+
// slides turn between them; dots in the footer follow the slide in front.
|
|
10
|
+
// Pictures drift inside their slide while they can be seen.
|
|
11
|
+
import { clamp, lerp } from "../../core/ease.js";
|
|
12
|
+
import { fillItem } from "./bento-grid.js";
|
|
13
|
+
import { list, num, str } from "../types.js";
|
|
14
|
+
export const RATIOS = ['4:5', '1:1', '9:16', '3:4', '16:9'];
|
|
15
|
+
const ratioOf = (r) => {
|
|
16
|
+
const [a, b] = str(r, '4:5').split(':').map(Number);
|
|
17
|
+
return a > 0 && b > 0 ? a / b : 0.8;
|
|
18
|
+
};
|
|
19
|
+
/** Header and footer of a post, each as a share of its width. */
|
|
20
|
+
const BAR = 0.14;
|
|
21
|
+
/** A slide's size on a W×H stage: `width` of it, or smaller so the whole post fits 92% of its height. */
|
|
22
|
+
export function slideSize(p, W, H) {
|
|
23
|
+
const ratio = ratioOf(p.ratio), bars = str(p.chrome) !== 'none' ? 2 * BAR : 0;
|
|
24
|
+
const w = Math.min((num(p.width) / 100) * W, (0.92 * H) / (1 / ratio + bars));
|
|
25
|
+
return { w, h: w / ratio };
|
|
26
|
+
}
|
|
27
|
+
const PUSH = 0.05;
|
|
28
|
+
/**
|
|
29
|
+
* Where the row stands at t: 0 is the first slide in front, 1 the second, and
|
|
30
|
+
* so on, easing between them. A loop turns on from the last slide to the first,
|
|
31
|
+
* reaching n (= 0 again) at the end of its last step.
|
|
32
|
+
*/
|
|
33
|
+
export function rowAt(t, n, hold, turn, loop, ease = (x) => x) {
|
|
34
|
+
if (n < 2 || t < hold)
|
|
35
|
+
return 0;
|
|
36
|
+
const P = hold + turn, steps = loop ? n : n - 1;
|
|
37
|
+
const m = Math.min(steps - 1, Math.floor((t - hold) / P));
|
|
38
|
+
return m + ease(clamp((t - hold - m * P) / turn));
|
|
39
|
+
}
|
|
40
|
+
/** Slide i's place relative to the front at row position c: 0 in front, 1 beside on the right, −1 on the left. */
|
|
41
|
+
export function placeOf(i, c, n, loop) {
|
|
42
|
+
const d = i - c;
|
|
43
|
+
if (!loop || n < 3)
|
|
44
|
+
return d;
|
|
45
|
+
// Around the loop: the shortest way, so the first slide waits on the right of the last.
|
|
46
|
+
return ((((d + n / 2) % n) + n) % n) - n / 2;
|
|
47
|
+
}
|
|
48
|
+
export const postCarousel = {
|
|
49
|
+
slug: 'scene/post-carousel',
|
|
50
|
+
summary: 'Slides shown one at a time as a post or posters, turning past in depth.',
|
|
51
|
+
props: {
|
|
52
|
+
slides: { type: 'string[]', required: true, label: 'The slides, in order: markup or a picture path each' },
|
|
53
|
+
handle: { type: 'string', default: 'yourbrand', label: 'Account name in the post header' },
|
|
54
|
+
avatar: { type: 'string', default: '', label: 'Picture for the avatar. Left out: the handle’s first letter on the accent' },
|
|
55
|
+
},
|
|
56
|
+
params: {
|
|
57
|
+
width: { type: 'number', default: 54, min: 20, max: 100, step: 1, unit: '% of stage width', label: 'Width of a slide (made smaller if the post would not fit the stage height)' },
|
|
58
|
+
ratio: { type: 'choice', default: '4:5', options: RATIOS, label: 'Shape of a slide, width : height' },
|
|
59
|
+
chrome: { type: 'choice', default: 'post', options: ['post', 'none'], label: 'post: a header and footer frame the slides; none: bare posters' },
|
|
60
|
+
hold: { type: 'number', default: 1.4, min: 0.4, max: 6, step: 0.05, unit: 's', label: 'How long each slide rests in front' },
|
|
61
|
+
turn: { type: 'number', default: 0.8, min: 0.3, max: 2, step: 0.05, unit: 's', label: 'Length of one turn to the next slide' },
|
|
62
|
+
angle: { type: 'number', default: 72, min: 0, max: 85, step: 1, unit: 'deg', label: 'How far the neighbours are turned away; 0 lays them flat beside the frame' },
|
|
63
|
+
loop: { type: 'boolean', default: false, label: 'Turn on from the last slide back to the first, so the film can loop' },
|
|
64
|
+
},
|
|
65
|
+
duration(props, p) {
|
|
66
|
+
const n = list(props.slides).length, hold = num(p.hold), P = hold + num(p.turn);
|
|
67
|
+
if (n < 2)
|
|
68
|
+
return hold;
|
|
69
|
+
return p.loop === true ? n * P : hold + (n - 1) * P;
|
|
70
|
+
},
|
|
71
|
+
cues(props, p, ctx) {
|
|
72
|
+
const n = list(props.slides).length, hold = num(p.hold), turn = num(p.turn);
|
|
73
|
+
const steps = n < 2 ? 0 : p.loop === true ? n : n - 1;
|
|
74
|
+
// A turn changes the slide in front and the strips beside it: about one and a half slides of the frame.
|
|
75
|
+
const [W, H] = ctx.size, { w, h } = slideSize(p, W, H);
|
|
76
|
+
const share = +Math.min(1, (1.5 * w * h) / (W * H)).toFixed(4);
|
|
77
|
+
return Array.from({ length: steps }, (_, m) => ({ at: hold + m * (hold + turn), length: turn, share }));
|
|
78
|
+
},
|
|
79
|
+
check(props, p) {
|
|
80
|
+
const issues = [];
|
|
81
|
+
const n = list(props.slides).length;
|
|
82
|
+
if (n < 1)
|
|
83
|
+
issues.push({ path: 'props.slides', message: 'There are no slides.', hint: 'Give at least two: one alone has nothing to turn to.' });
|
|
84
|
+
if (p.loop === true && n > 0 && n < 3)
|
|
85
|
+
issues.push({ path: 'params.loop', message: `A loop of ${n} slide${n === 1 ? '' : 's'} has no slide waiting on each side.`, hint: 'Give three slides or more, or set loop to false.' });
|
|
86
|
+
return issues;
|
|
87
|
+
},
|
|
88
|
+
build(el, props, p, ctx) {
|
|
89
|
+
const doc = el.ownerDocument;
|
|
90
|
+
const [W, H] = ctx.size;
|
|
91
|
+
const slides = list(props.slides), n = slides.length;
|
|
92
|
+
const chrome = str(p.chrome) !== 'none', ratio = ratioOf(p.ratio), loop = p.loop === true;
|
|
93
|
+
const { w, h } = slideSize(p, W, H);
|
|
94
|
+
const bar = chrome ? BAR * w : 0, gap = 0.035 * w, R = 0.035 * w, u = w / 1000;
|
|
95
|
+
const hold = num(p.hold), turn = Math.max(0.01, num(p.turn)), P = hold + turn, angle = num(p.angle);
|
|
96
|
+
const ease = ctx.ease(ctx.tokens.ease_move);
|
|
97
|
+
const wrap = doc.createElement('div');
|
|
98
|
+
wrap.style.cssText = `position:relative;width:${w}px;height:${h + 2 * bar}px;text-align:left`;
|
|
99
|
+
const row = doc.createElement('div');
|
|
100
|
+
row.style.cssText = `position:absolute;left:0;top:${bar}px;width:${w}px;height:${h}px;perspective:${(2.5 * w).toFixed(0)}px;transform-style:preserve-3d`;
|
|
101
|
+
const cards = slides.map((s) => {
|
|
102
|
+
const card = doc.createElement('div');
|
|
103
|
+
// Bare posters take the stage's card radius and shadow when it sets them (--m-card-radius, --m-card-shadow).
|
|
104
|
+
card.style.cssText = `position:absolute;inset:0;overflow:hidden;background:var(--m-bg-surface);border-radius:${chrome ? '0' : `var(--m-card-radius, ${R}px)`};`
|
|
105
|
+
+ `backface-visibility:hidden;font-size:${(64 * u).toFixed(2)}px;box-shadow:var(--m-card-shadow, 0 ${24 * u}px ${60 * u}px rgba(0,0,0,.28))`;
|
|
106
|
+
const inner = doc.createElement('div');
|
|
107
|
+
inner.style.cssText = 'position:absolute;inset:0;display:grid;place-items:center;transform-origin:50% 50%';
|
|
108
|
+
fillItem(inner, s);
|
|
109
|
+
card.appendChild(inner);
|
|
110
|
+
row.appendChild(card);
|
|
111
|
+
return { card, inner };
|
|
112
|
+
});
|
|
113
|
+
wrap.appendChild(row);
|
|
114
|
+
const dots = [];
|
|
115
|
+
if (chrome) {
|
|
116
|
+
const font = 'var(--m-font-body)';
|
|
117
|
+
const barCss = (top, corners) => `position:absolute;left:0;top:${top}px;width:${w}px;height:${bar}px;box-sizing:border-box;`
|
|
118
|
+
+ `display:flex;align-items:center;gap:${22 * u}px;padding:0 ${36 * u}px;background:var(--m-bg-surface);color:var(--m-text-primary);`
|
|
119
|
+
+ `border-radius:${corners};font:600 ${34 * u}px/1 ${font}`;
|
|
120
|
+
const head = doc.createElement('div');
|
|
121
|
+
head.style.cssText = barCss(0, `${R}px ${R}px 0 0`) + `;box-shadow:inset 0 -1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)`;
|
|
122
|
+
const av = doc.createElement('div');
|
|
123
|
+
const size = 64 * u;
|
|
124
|
+
av.style.cssText = `flex:none;width:${size}px;height:${size}px;border-radius:50%;overflow:hidden;position:relative;display:grid;place-items:center;`
|
|
125
|
+
+ `background:var(--m-accent);color:var(--m-text-on-accent);font:700 ${30 * u}px/1 ${font}`;
|
|
126
|
+
const avatar = str(props.avatar);
|
|
127
|
+
if (avatar)
|
|
128
|
+
fillItem(av, avatar);
|
|
129
|
+
else
|
|
130
|
+
av.textContent = (str(props.handle, 'y').trim()[0] ?? 'y').toUpperCase();
|
|
131
|
+
const name = doc.createElement('span');
|
|
132
|
+
name.textContent = str(props.handle, 'yourbrand');
|
|
133
|
+
name.style.cssText = 'flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis';
|
|
134
|
+
const more = doc.createElement('span');
|
|
135
|
+
more.textContent = '•••';
|
|
136
|
+
more.style.cssText = `letter-spacing:${2 * u}px;font-size:${22 * u}px;color:var(--m-text-muted)`;
|
|
137
|
+
head.append(av, name, more);
|
|
138
|
+
const foot = doc.createElement('div');
|
|
139
|
+
foot.style.cssText = barCss(bar + h, `0 0 ${R}px ${R}px`) + `;box-shadow:inset 0 1px 0 color-mix(in srgb, var(--m-text-primary) 8%, transparent)`;
|
|
140
|
+
const icon = (d, fill = 'none') => {
|
|
141
|
+
const s = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
142
|
+
s.setAttribute('viewBox', '0 0 24 24');
|
|
143
|
+
s.setAttribute('width', String(50 * u));
|
|
144
|
+
s.setAttribute('height', String(50 * u));
|
|
145
|
+
s.style.cssText = 'flex:none;display:block';
|
|
146
|
+
s.innerHTML = `<path d="${d}" fill="${fill}" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round" stroke-linecap="round"/>`;
|
|
147
|
+
return s;
|
|
148
|
+
};
|
|
149
|
+
const heart = icon('M12 20.5s-7.5-4.6-7.5-10.2A4.3 4.3 0 0 1 12 7.6a4.3 4.3 0 0 1 7.5 2.7c0 5.6-7.5 10.2-7.5 10.2Z', 'currentColor');
|
|
150
|
+
heart.style.color = 'var(--m-accent)';
|
|
151
|
+
const bubble = icon('M20 11.5a8 8 0 0 1-11.6 7.1L4 20l1.4-4.2A8 8 0 1 1 20 11.5Z');
|
|
152
|
+
const send = icon('M21 3 10 13.5M21 3l-6.5 18-4.5-7.5L3 9.5 21 3Z');
|
|
153
|
+
const pager = doc.createElement('div');
|
|
154
|
+
pager.style.cssText = `flex:1;display:flex;justify-content:center;gap:${10 * u}px`;
|
|
155
|
+
for (let i = 0; i < Math.min(n, 12); i++) {
|
|
156
|
+
const dot = doc.createElement('i');
|
|
157
|
+
dot.style.cssText = `display:block;width:${11 * u}px;height:${11 * u}px;border-radius:50%;background:var(--m-text-primary)`;
|
|
158
|
+
pager.appendChild(dot);
|
|
159
|
+
dots.push(dot);
|
|
160
|
+
}
|
|
161
|
+
const save = icon('M6 3.5h12v17l-6-4.5-6 4.5v-17Z');
|
|
162
|
+
foot.append(heart, bubble, send, pager, save);
|
|
163
|
+
wrap.append(head, foot);
|
|
164
|
+
}
|
|
165
|
+
el.appendChild(wrap);
|
|
166
|
+
// When each slide starts to come to the front (the first is there from the start).
|
|
167
|
+
const arrives = (i) => (i === 0 ? -turn : hold + (i - 1) * P);
|
|
168
|
+
const L = n * P;
|
|
169
|
+
return {
|
|
170
|
+
seek(t) {
|
|
171
|
+
const c = rowAt(t, n, hold, turn, loop, ease);
|
|
172
|
+
cards.forEach(({ card, inner }, i) => {
|
|
173
|
+
const d = placeOf(i, c, n, loop);
|
|
174
|
+
const a = clamp(d, -1, 1), far = Math.max(0, Math.abs(d) - 1);
|
|
175
|
+
// Hinged on the edge nearest the frame, so a neighbour's near edge stays a gap from it.
|
|
176
|
+
card.style.transformOrigin = d >= 0 ? '0% 50%' : '100% 50%';
|
|
177
|
+
// Beyond the neighbours, slides wait far behind them, so the slide turning to the
|
|
178
|
+
// front never passes behind one, and fade in over the end of the turn that makes
|
|
179
|
+
// them a neighbour.
|
|
180
|
+
card.style.transform = `translateX(${(a * (w + gap)).toFixed(2)}px) translateZ(${(-(Math.abs(a) * 0.06 + far * 1.5) * w).toFixed(2)}px) rotateY(${(angle * a).toFixed(3)}deg)`;
|
|
181
|
+
card.style.opacity = far > 0 ? clamp((0.6 - far) / 0.6).toFixed(4) : '';
|
|
182
|
+
card.style.visibility = far < 1 ? 'inherit' : 'hidden';
|
|
183
|
+
card.style.zIndex = String(10 - Math.round(Math.abs(d) * 2));
|
|
184
|
+
// Linear drift from the moment it starts to arrive until it has gone.
|
|
185
|
+
const since = loop ? ((((t - arrives(i)) % L) + L) % L) : t - arrives(i);
|
|
186
|
+
inner.style.transform = `scale(${(1 + PUSH * (1 - clamp(since / (P + turn)))).toFixed(4)})`;
|
|
187
|
+
});
|
|
188
|
+
dots.forEach((dot, i) => {
|
|
189
|
+
const near = Math.max(0, 1 - Math.abs(placeOf(i, c, n, loop)));
|
|
190
|
+
dot.style.opacity = lerp(0.22, 1, near).toFixed(3);
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Primitive } from '../types.ts';
|
|
2
|
+
export declare const ORDERS: readonly ["down", "up", "center", "edges", "random"];
|
|
3
|
+
export declare const DIRECTIONS: readonly ["left", "right", "alternate", "weave"];
|
|
4
|
+
export declare const EMPTY: readonly ["none", "start", "end", "both"];
|
|
5
|
+
/** What the frame shows, in order: a picture's index, or null for the bare ground. */
|
|
6
|
+
export declare function statesOf(pictures: number, empty: string): (number | null)[];
|
|
7
|
+
/**
|
|
8
|
+
* How one change is clocked. `shift` is the whole change, first strip leaving to
|
|
9
|
+
* last strip landing, so a change lasts exactly what the film says (a beat, two).
|
|
10
|
+
* The stagger is spread inside it: each strip starts `delays[row]` in and travels
|
|
11
|
+
* for `travel`. A stagger too wide for the change is scaled down to fit.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stripClock(rows: number, shift: number, stagger: number, order: string, seed?: number): {
|
|
14
|
+
delays: number[];
|
|
15
|
+
travel: number;
|
|
16
|
+
};
|
|
17
|
+
export interface StripTiming {
|
|
18
|
+
/** When each change starts (change k leads into state k + 1). */
|
|
19
|
+
changes: number[];
|
|
20
|
+
/** Length of one change. */
|
|
21
|
+
change: number;
|
|
22
|
+
duration: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every state holds for its own time (`holds[s]`), then the next change runs. The
|
|
26
|
+
* last state holds, then the layer ends. A number holds every state alike.
|
|
27
|
+
*/
|
|
28
|
+
export declare function stripTiming(states: number, holds: number | readonly number[], change: number): StripTiming;
|
|
29
|
+
/** How long each state holds: pictures for `hold`, the bare ground for `ground` (0: as long as a picture). */
|
|
30
|
+
export declare const holdsOf: (states: readonly (number | null)[], hold: number, ground: number) => number[];
|
|
31
|
+
/**
|
|
32
|
+
* Which side the incoming picture enters strip `row` from in change `k`: +1 the
|
|
33
|
+
* right edge, −1 the left. `direction` is the way the strips run, as for
|
|
34
|
+
* transition/band-sweep: `left` runs leftward, so it enters from the right.
|
|
35
|
+
* `alternate` turns every other strip; `weave` also turns the whole pattern each
|
|
36
|
+
* change, so strips never repeat a side.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sideOf(direction: string, row: number, k: number): 1 | -1;
|
|
39
|
+
/**
|
|
40
|
+
* Where one strip stands in change k at time t: `u` is the eased travel of the
|
|
41
|
+
* incoming picture (0 not yet moving, 1 landed). Before the change the strip shows
|
|
42
|
+
* state k; after it, state k + 1.
|
|
43
|
+
*/
|
|
44
|
+
export declare function stripAt(t: number, timing: StripTiming, delays: readonly number[], row: number, shift: number, ease: (x: number) => number): {
|
|
45
|
+
from: number;
|
|
46
|
+
to: number;
|
|
47
|
+
u: number;
|
|
48
|
+
};
|
|
49
|
+
export declare const stripCycle: Primitive;
|