Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

feat(onboarding): a camera on the tour, sharper stacks, steadier windows

Deepender25385d211c4e47
diff --git a/src/Onboarding.tsx b/src/Onboarding.tsx
index 0e20788..33e2cfb 100644
--- a/src/Onboarding.tsx
+++ b/src/Onboarding.tsx
@@ -21,8 +21,8 @@ import { applyReduceMotion } from './lib/theme'
import { useTranslation } from './i18n'
import { DEFAULT_SETTINGS, type Settings, type StickPosition } from '../shared/types'
import { PEN_PATH, PEN_TRANSFORM, PEN_WIDTH, GLASS_BOX, SHADOW_BOX, BLUR_BOX, penProgress } from './onboarding/lettering'
-import { DEMOS, Run, STOP, itemsFor, playLooped, resetDemoState, watchActivity, type Stage } from './onboarding/tour'
-import { laptopBar, tourBar, shelfTransform, SHELF_SCALE, TOUR_SCREEN_TOP } from './onboarding/edgeBar'
+import { DEMOS, PREVIEW_PAN, Run, STOP, itemsFor, playLooped, resetDemoState, watchActivity, type Stage } from './onboarding/tour'
+import { laptopBar, tourBar, shelfTransform, topBarLength, SHELF_SCALE, TOUR_SCREEN_TOP } from './onboarding/edgeBar'
import { PAGE_LINES, STACK_FILES } from './onboarding/demoItems'
import { Autoplay, readingMs } from './onboarding/autoplay'
import { fileIconUrl, fileKindOf } from './lib/fileKind'
@@ -100,6 +100,7 @@ export function Onboarding() {
const notesImageRef = useRef<HTMLDivElement>(null)
const browserRef = useRef<HTMLDivElement>(null)
const explorerRef = useRef<HTMLDivElement>(null)
+ const lensRef = useRef<HTMLDivElement>(null)
const penRef = useRef<SVGPathElement>(null)
const lettersRef = useRef<HTMLDivElement>(null)
const shadowRef = useRef<SVGImageElement>(null)
@@ -140,6 +141,7 @@ export function Onboarding() {
notesImage: notesImageRef.current!,
browser: browserRef.current!,
explorer: explorerRef.current!,
+ lens: lensRef.current!,
showShelf: (on) => {
setShelf(on)
setBarShown(!on)
@@ -163,6 +165,7 @@ export function Onboarding() {
const unwatch = watchActivity()
document.body.style.setProperty('--ob-shelf-scale', String(SHELF_SCALE))
document.body.style.setProperty('--ob-shelf-top', `${TOUR_SCREEN_TOP}px`)
+ document.body.style.setProperty('--ob-preview-pan', `${-PREVIEW_PAN}px`)
void edge.loadState().then(async ({ settings }) => {
if (cancelled) return
setReal(settings)
@@ -193,6 +196,7 @@ export function Onboarding() {
document.body.classList.remove('ob-tour')
document.body.style.removeProperty('--ob-shelf-scale')
document.body.style.removeProperty('--ob-shelf-top')
+ document.body.style.removeProperty('--ob-preview-pan')
runRef.current?.cancel()
timers.current.forEach(clearTimeout)
}
@@ -286,6 +290,13 @@ export function Onboarding() {
atRef.current = at
goRef.current = go
+ // The preview step fades the flyout's last stretch out above the text (see .ob-preview-step).
+ useEffect(() => {
+ document.body.classList.toggle('ob-preview-step', steps[at].key === 'preview')
+ return () => document.body.classList.remove('ob-preview-step')
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [at])
+
// Autoplay's clock for a step starts when its text is up: after the intro, then on each step change.
useEffect(() => {
if (intro !== 'done') return
@@ -307,6 +318,7 @@ export function Onboarding() {
const locked = intro !== 'done'
// The tour's shelf is docked at the top; the settings frame shows the user's real choice.
const demo = useStore((st) => st.settings)
+ const shelfOpen = useStore((st) => st.open)
const showReal = at === last && realEdge && !!real
const edgeNow: StickPosition = showReal ? barPos : 'top'
const barStyle = showReal && real ? laptopBar(edgeNow, real) : tourBar(demo)
@@ -320,119 +332,125 @@ export function Onboarding() {
<div className={`ob${intro === 'writing' ? '' : ' ob-focus'}${intro === 'done' ? ' ob-done' : ''}`}>
<div className="ob-stage" ref={stageRef}>
<div className="ob-scene">
- {/* The cloud wallpaper: one pixel per 2px dither cell, drawn crisp (it never moves). */}
+ {/* The cloud wallpaper: one pixel per 2px dither cell, drawn crisp (it never moves, not even with the camera). */}
<img className="ob-sky" src={skyUrl} alt="" />
- {/* A web page, for the copy demo: a sentence, the address and the photo get copied. */}
- <div className="ob-win ob-browser" ref={browserRef}>
- <div className="ob-win-bar">
- <span className="ob-tab"><i>W</i>Sea of clouds - Wikipedia</span>
- <Caption />
- </div>
- <div className="ob-address">
- <span className="ob-url"><i className="ob-hl" />en.wikipedia.org/wiki/Sea_of_clouds</span>
- </div>
- <div className="ob-page">
- <div className="ob-article">
- <b>Sea of clouds</b>
- {PAGE_LINES.map((line) => <span key={line} className="ob-line"><i className="ob-hl" />{line}</span>)}
- <span className="ob-rest">It is most often seen on cold, clear mornings.</span>
- </div>
- <div className="ob-photo" />
- </div>
- <div className="ob-menu">
- <span>Open image in new tab</span>
- <span>Save image as…</span>
- <span className="is-copy">Copy image</span>
- <span>Copy image link</span>
- </div>
- </div>
+ {/* The camera: the laptop, what is on its screen and the pointer, pushed in on the action (lens.ts). */}
+ <div className="ob-lens" ref={lensRef}>
- {/* File Explorer, for the drag-in demo. */}
- <div className="ob-win ob-explorer" ref={explorerRef}>
- <div className="ob-win-bar">
- <span className="ob-notes-title"><i className="ob-folder" />Documents</span>
- <Caption />
- </div>
- <div className="ob-files">
- <div className="ob-files-head"><span>Name</span><span>Size</span></div>
- <i className="ob-band" />
- {FOLDER.map(([name, size]) => (
- <div key={name} className={`ob-file${name.endsWith('.pdf') ? ' is-pdf' : ''}`}>
- <img src={fileIconUrl(fileKindOf(name))} alt="" />
- <span>{name}</span>
- <em>{Math.round(size / 1024).toLocaleString('en-US')} KB</em>
+ {/* A web page, for the copy demo: a sentence, the address and the photo get copied. */}
+ <div className="ob-win ob-browser" ref={browserRef}>
+ <div className="ob-win-bar">
+ <span className="ob-tab"><i>W</i>Sea of clouds - Wikipedia</span>
+ <Caption />
+ </div>
+ <div className="ob-address">
+ <span className="ob-url"><i className="ob-hl" />en.wikipedia.org/wiki/Sea_of_clouds</span>
+ </div>
+ <div className="ob-page">
+ <div className="ob-article">
+ <b>Sea of clouds</b>
+ {PAGE_LINES.map((line) => <span key={line} className="ob-line"><i className="ob-hl" />{line}</span>)}
+ <span className="ob-rest">It is most often seen on cold, clear mornings.</span>
</div>
- ))}
+ <div className="ob-photo" />
+ </div>
+ <div className="ob-menu">
+ <span>Open image in new tab</span>
+ <span>Save image as…</span>
+ <span className="is-copy">Copy image</span>
+ <span>Copy image link</span>
+ </div>
</div>
- </div>
- {/* Another app, for the drag demo. */}
- <div className="ob-notes" ref={notesRef}>
- <div className="ob-notes-bar">
- <span className="ob-notes-title"><i />Trip plan</span>
- <Caption />
- </div>
- <div className="ob-notes-body">
- <b>Weekend at the summit</b>
- <p>Sat · Trailhead 6:30, top by noon</p>
- <p>Sun · Ridge walk above the clouds</p>
- <div className="ob-notes-image" ref={notesImageRef} />
+ {/* File Explorer, for the drag-in demo. */}
+ <div className="ob-win ob-explorer" ref={explorerRef}>
+ <div className="ob-win-bar">
+ <span className="ob-notes-title"><i className="ob-folder" />Documents</span>
+ <Caption />
+ </div>
+ <div className="ob-files">
+ <div className="ob-files-head"><span>Name</span><span>Size</span></div>
+ <i className="ob-band" />
+ {FOLDER.map(([name, size]) => (
+ <div key={name} className={`ob-file${name.endsWith('.pdf') ? ' is-pdf' : ''}`}>
+ <img src={fileIconUrl(fileKindOf(name))} alt="" />
+ <span>{name}</span>
+ <em>{Math.round(size / 1024).toLocaleString('en-US')} KB</em>
+ </div>
+ ))}
+ </div>
</div>
- </div>
- {/* The real shelf, inert: the tour drives it. */}
- {ready && (
- <div
- className={`ob-shelf${shelf ? '' : ' is-hidden'}`}
- style={{ transform: shelfTransform(cam) }}
- aria-hidden
- >
- <Panel />
+ {/* Another app, for the drag demo. */}
+ <div className="ob-notes" ref={notesRef}>
+ <div className="ob-notes-bar">
+ <span className="ob-notes-title"><i />Trip plan</span>
+ <Caption />
+ </div>
+ <div className="ob-notes-body">
+ <b>Weekend at the summit</b>
+ <p>Sat · Trailhead 6:30, top by noon</p>
+ <p>Sun · Ridge walk above the clouds</p>
+ <div className="ob-notes-image" ref={notesImageRef} />
+ </div>
</div>
- )}
-
- {/* The welcome and settings frames dim only below the laptop, so its screen stays the lit object. */}
- <div className={`ob-below${cam === 'frame' ? '' : ' is-off'}`} aria-hidden />
-
- {/* The camera on the laptop: the whole laptop; the tour's push-in on its top edge; or (settings) a
- close-up framed on the user's edge. The bar is inside, so it stays attached to the screen edge. */}
- <div className={`ob-cam${cam === 'tour' ? ' is-tour' : ''}${closeUp ? ` is-close is-${edgeNow}` : ''}`} aria-hidden>
- <div className="ob-laptop">
- <div className="ob-bezel" />
- <div className="ob-base" />
- {/* The screen's taskbar: up whenever the whole laptop is in view (welcome, settings). */}
- <div className={`ob-taskbar${cam === 'frame' ? ' is-on' : ''}`}>
- <div className="ob-task-apps"><i className="ob-start" /><i className="ob-search" /><i /><i /><i /></div>
- <div className="ob-task-tray">
- <svg width="9" height="7" viewBox="0 0 9 7"><path d="M.5 2.6a5.6 5.6 0 0 1 8 0M2 4.1a3.4 3.4 0 0 1 5 0M3.5 5.6a1.3 1.3 0 0 1 2 0" fill="none" stroke="#fff" strokeWidth=".9" strokeLinecap="round" /></svg>
- <svg width="11" height="6" viewBox="0 0 11 6"><rect x=".5" y=".5" width="9" height="5" rx="1.2" fill="none" stroke="#fff" strokeWidth=".8" /><rect x="1.6" y="1.6" width="6" height="2.8" rx=".5" fill="#fff" /><rect x="9.8" y="2" width=".8" height="2" rx=".3" fill="#fff" /></svg>
- <span><b>12:01</b><b>27-10-2026</b></span>
+
+ {/* The real shelf, inert: the tour drives it. */}
+ {ready && (
+ <div
+ className={`ob-shelf${shelf ? '' : ' is-hidden'}${shelfOpen ? ' is-open' : ''}`}
+ style={{ transform: shelfTransform(cam), '--ob-bar-w': `${topBarLength(demo.hotZoneHeight)}px` } as React.CSSProperties}
+ aria-hidden
+ >
+ <Panel />
+ </div>
+ )}
+
+ {/* The welcome and settings frames dim only below the laptop, so its screen stays the lit object. */}
+ <div className={`ob-below${cam === 'frame' ? '' : ' is-off'}`} aria-hidden />
+
+ {/* The camera on the laptop: the whole laptop; the tour's push-in on its top edge; or (settings) a
+ close-up framed on the user's edge. The bar is inside, so it stays attached to the screen edge. */}
+ <div className={`ob-cam${cam === 'tour' ? ' is-tour' : ''}${closeUp ? ` is-close is-${edgeNow}` : ''}`} aria-hidden>
+ <div className="ob-laptop">
+ <div className="ob-bezel" />
+ <div className="ob-base" />
+ {/* The screen's taskbar: up whenever the whole laptop is in view (welcome, settings). */}
+ <div className={`ob-taskbar${cam === 'frame' ? ' is-on' : ''}`}>
+ <div className="ob-task-apps"><i className="ob-start" /><i className="ob-search" /><i /><i /><i /></div>
+ <div className="ob-task-tray">
+ <svg width="9" height="7" viewBox="0 0 9 7"><path d="M.5 2.6a5.6 5.6 0 0 1 8 0M2 4.1a3.4 3.4 0 0 1 5 0M3.5 5.6a1.3 1.3 0 0 1 2 0" fill="none" stroke="#fff" strokeWidth=".9" strokeLinecap="round" /></svg>
+ <svg width="11" height="6" viewBox="0 0 11 6"><rect x=".5" y=".5" width="9" height="5" rx="1.2" fill="none" stroke="#fff" strokeWidth=".8" /><rect x="1.6" y="1.6" width="6" height="2.8" rx=".5" fill="#fff" /><rect x="9.8" y="2" width=".8" height="2" rx=".3" fill="#fff" /></svg>
+ <span><b>12:01</b><b>27-10-2026</b></span>
+ </div>
</div>
</div>
+ {/* Keyed by edge: moving to another edge fades in there instead of morphing across the screen. */}
+ <div key={edgeNow} className={`ob-bar${barShown ? '' : ' is-hidden'}`} style={barStyle} />
+ </div>
+
+ <div className="ob-cursor" ref={cursorRef} aria-hidden>
+ {/* Dark-mode pointer: a black arrowhead (no stem, softly rounded) with a hairline light edge. */}
+ <svg width="16" height="18" viewBox="0 0 16 18">
+ <path
+ d="M2.9 2.1C2.3 1.6 1.7 1.9 1.7 2.7v11.6c0 .9.9 1.3 1.6.7l2.9-2.7c.3-.3.7-.4 1.1-.4l4.4-.1c.9 0 1.3-1.1.6-1.7z"
+ fill="#000"
+ stroke="#fff"
+ strokeWidth="0.6"
+ strokeLinejoin="round"
+ />
+ </svg>
</div>
- {/* Keyed by edge: moving to another edge fades in there instead of morphing across the screen. */}
- <div key={edgeNow} className={`ob-bar${barShown ? '' : ' is-hidden'}`} style={barStyle} />
</div>
+ {/* Ctrl+C, outside the camera: placed beside a window as it is framed on screen (tour.ts keys). */}
<div className="ob-keys" ref={keysRef} aria-hidden>
<div><kbd>Ctrl</kbd><b>+</b><kbd>C</kbd></div>
<span ref={keysLabelRef} />
</div>
- <div className="ob-cursor" ref={cursorRef} aria-hidden>
- {/* Dark-mode pointer: a black arrowhead (no stem, softly rounded) with a hairline light edge. */}
- <svg width="16" height="18" viewBox="0 0 16 18">
- <path
- d="M2.9 2.1C2.3 1.6 1.7 1.9 1.7 2.7v11.6c0 .9.9 1.3 1.6.7l2.9-2.7c.3-.3.7-.4 1.1-.4l4.4-.1c.9 0 1.3-1.1.6-1.7z"
- fill="#000"
- stroke="#fff"
- strokeWidth="0.6"
- strokeLinejoin="round"
- />
- </svg>
- </div>
- <div className={`ob-ui${locked ? ' is-locked' : ''}${s.key === 'preview' ? ' is-side' : ''}${s.key === 'settings' ? ' is-low' : ''}`}>
+ <div className={`ob-ui${locked ? ' is-locked' : ''}${s.key === 'settings' ? ' is-low' : ''}`}>
<div className="ob-progress">
{/* The active dash fills as the step plays and rests (autoplay); the last one is simply full. */}
<div className="ob-dots">
diff --git a/src/onboarding/autoplay.ts b/src/onboarding/autoplay.ts
index 74dc5c6..a5f0820 100644
--- a/src/onboarding/autoplay.ts
+++ b/src/onboarding/autoplay.ts
@@ -19,14 +19,14 @@ const MAX_REST = 6000
/** How long each step's demo runs, from the step appearing to its end (measured), for pacing the fill. */
const DEMO_MS: Record<string, number> = {
- welcome: 3900,
- collect: 11550,
- dropin: 5800,
- stacks: 4800,
- drag: 3350,
- ungroup: 5000,
- merge: 3700,
- preview: 2900
+ welcome: 4200,
+ collect: 11600,
+ dropin: 5750,
+ stacks: 5150,
+ drag: 3850,
+ ungroup: 4900,
+ merge: 3650,
+ preview: 3600
}
/** Han, kana and Hangul: one character carries about a word. */
diff --git a/src/onboarding/demoItems.ts b/src/onboarding/demoItems.ts
index e7a88ad..37e1f25 100644
--- a/src/onboarding/demoItems.ts
+++ b/src/onboarding/demoItems.ts
@@ -71,11 +71,18 @@ export function demoPdf(at: number): ClipboardItemDto {
return files('demo-pdf', [['Itinerary.pdf', 412_000]], at)
}
-/** Three files of different kinds, selected in File Explorer and copied at once: they arrive as one stack. */
+/**
+ * Five files of different kinds, selected in File Explorer and copied at once: they arrive as one stack.
+ * The first is the one pulled out and then combined with the (blue) photo: the slides' orange folder
+ * stands in front of it, where Word's blue would blend in. The four left are the stack the preview
+ * opens.
+ */
export const STACK_FILES: Array<[string, number]> = [
- ['Packing list.docx', 96_426],
+ ['Trip slides.pptx', 2_318_400],
['Budget.xlsx', 144_639],
- ['Trip slides.pptx', 2_318_400]
+ ['Packing list.docx', 96_426],
+ ['Summit photos.zip', 18_874_368],
+ ['Checklist.txt', 2_150]
]
export function demoStack(at: number, names = STACK_FILES): ClipboardItemDto {
@@ -87,7 +94,7 @@ export function demoSingle(at: number, name: [string, number]): ClipboardItemDto
return files('demo-single', [name], at)
}
-/** The image dropped onto the single file: one stack holding both. */
+/** The image dropped onto the single file: one stack holding both, the file first (main: the target's files, then the dropped one's). */
export function demoMerged(at: number, name: [string, number]): ClipboardItemDto {
return {
id: 'demo-single',
@@ -96,8 +103,8 @@ export function demoMerged(at: number, name: [string, number]): ClipboardItemDto
pinned: false,
data: {
kind: 'files',
- paths: [DIR + 'Summit.png', DIR + name[0]],
- entries: [file('Summit.png', 1_284_600), file(name[0], name[1])]
+ paths: [DIR + name[0], DIR + 'Summit.png'],
+ entries: [file(name[0], name[1]), file('Summit.png', 1_284_600)]
}
}
}
diff --git a/src/onboarding/edgeBar.ts b/src/onboarding/edgeBar.ts
index ba4ac6f..0bdd37e 100644
--- a/src/onboarding/edgeBar.ts
+++ b/src/onboarding/edgeBar.ts
@@ -45,7 +45,7 @@ export const shelfTransform = (cam: 'frame' | 'tour') =>
: `translateY(${LAPTOP_SCREEN.top}px) scale(${SHELF_SCALE / TOUR.scale})`
/** Length of the top dock's bar (Panel: triggerWidthPx). */
-function topBarLength(hotZoneHeight: number): number {
+export function topBarLength(hotZoneHeight: number): number {
return hotZoneHeight >= 0.55 ? 575 : hotZoneHeight >= 0.35 ? 400 : 275
}
diff --git a/src/onboarding/lens.ts b/src/onboarding/lens.ts
new file mode 100644
index 0000000..b149b2e
--- /dev/null
+++ b/src/onboarding/lens.ts
@@ -0,0 +1,120 @@
+/**
+ * The tour's camera: the scene in front of the wallpaper (the laptop, the
+ * shelf, the other apps, the pointer and what it drags) sits under one lens
+ * that pushes in on wherever the action is and pulls back to show where it
+ * lands, the way screen recordings do. The wallpaper stays behind it (its
+ * crisp dither would break up when scaled), and the step's text, dots,
+ * buttons and the Ctrl+C keys are outside it and never move.
+ *
+ * A move is a scale transform (smooth to animate); once the camera has
+ * arrived it holds with CSS zoom instead, which lays the scene out at the
+ * zoomed size, so held text and cards are drawn crisp rather than stretched.
+ *
+ * The camera makes a few decisive moves, it does not drift: each step
+ * pushes in once where its action starts, holds still through the fine work,
+ * and pulls back with the pointer as the action reaches its destination.
+ * Demos measure everything in scene pixels (toLocal), which the lens leaves
+ * untouched, so the pointer lands on the same card whatever the camera does.
+ * Under reduced motion the lens stays at rest.
+ */
+
+/** The scene the lens covers, in its own pixels. */
+const W = 800
+
+/** The camera's own moves: they ease in (no lurch) and land without a long creep. */
+export const CAM = 'cubic-bezier(.5,0,.25,1)'
+
+export interface Rect {
+ left: number
+ top: number
+ right: number
+ bottom: number
+ width: number
+ height: number
+}
+
+/** A framing: scale `k`, then a move by (x, y), from the scene's top-left corner. */
+export interface View {
+ k: number
+ x: number
+ y: number
+}
+
+export const REST: View = { k: 1, x: 0, y: 0 }
+
+const reduced = () => document.documentElement.dataset.motion === 'reduce'
+
+/** Where each lens is headed (its last framing), for placing things outside it. */
+const target = new WeakMap<HTMLElement, View>()
+/** The pending switch to a held framing, per lens. */
+const holding = new WeakMap<HTMLElement, number>()
+
+const atRest = (v: View) => v.k === 1 && v.x === 0 && v.y === 0
+const moving = (v: View) => (atRest(v) ? 'none' : `translate(${v.x}px, ${v.y}px) scale(${v.k})`)
+
+/** Arrived: hold `v` with CSS zoom (the move's translate is in zoomed pixels there, hence / k). */
+function hold(lens: HTMLElement, v: View) {
+ lens.style.transition = 'none'
+ lens.style.zoom = atRest(v) ? '' : String(v.k)
+ lens.style.transform = atRest(v) ? 'none' : `translate(${v.x / v.k}px, ${v.y / v.k}px)`
+}
+
+/**
+ * A framing at scale `k` that puts the scene point `focus` at the window point `at`. It never shows past
+ * the laptop's sides, nor (unless `free`) above the screen's top edge.
+ */
+export function aim(k: number, focus: { x: number; y: number }, at: { x: number; y: number }, free = false): View {
+ const x = Math.min(0, Math.max(W * (1 - k), at.x - focus.x * k))
+ const y = free ? at.y - focus.y * k : Math.min(0, at.y - focus.y * k)
+ return { k, x: Math.round(x), y: Math.round(y) }
+}
+
+/** Move the camera to `v` over `ms`. */
+export function zoomTo(lens: HTMLElement, v: View, ms: number, easing = CAM): void {
+ const from = target.get(lens) ?? REST
+ target.set(lens, v)
+ if (reduced()) return
+ // already there, or on its way there: let it be
+ if (from.k === v.k && from.x === v.x && from.y === v.y) return
+ clearTimeout(holding.get(lens))
+ holding.delete(lens)
+ if (lens.style.zoom) {
+ // from a held framing back to the same picture as a transform, so the move can animate from it
+ lens.style.transition = 'none'
+ lens.style.zoom = ''
+ lens.style.transform = moving(from)
+ void lens.offsetWidth
+ }
+ if (ms <= 0) {
+ hold(lens, v)
+ return
+ }
+ lens.style.transition = `transform ${ms}ms ${easing}`
+ lens.style.transform = moving(v)
+ holding.set(lens, window.setTimeout(() => {
+ holding.delete(lens)
+ hold(lens, v)
+ }, ms + 40))
+}
+
+/** Back to the whole scene. */
+export function zoomRest(lens: HTMLElement, ms: number, easing = CAM): void {
+ zoomTo(lens, REST, ms, easing)
+}
+
+/** A scene point where it will be in the window once the camera has arrived. */
+export function toScreen(lens: HTMLElement, p: { x: number; y: number }): { x: number; y: number } {
+ const v = reduced() ? REST : (target.get(lens) ?? REST)
+ return { x: p.x * v.k + v.x, y: p.y * v.k + v.y }
+}
+
+/** A client rect in scene pixels, whatever the lens (and the intro's scene scale) is doing right now. */
+export function toLocal(lens: HTMLElement, r: DOMRect): Rect {
+ const b = lens.getBoundingClientRect()
+ const s = b.width / W || 1
+ const left = (r.left - b.left) / s
+ const top = (r.top - b.top) / s
+ const width = r.width / s
+ const height = r.height / s
+ return { left, top, width, height, right: left + width, bottom: top + height }
+}
diff --git a/src/onboarding/tour.ts b/src/onboarding/tour.ts
index b022956..eea3439 100644
--- a/src/onboarding/tour.ts
+++ b/src/onboarding/tour.ts
@@ -5,6 +5,10 @@
* talk to main are never called (they would act on the user's real panel
* window); state is written with useStore.setState directly.
*
+ * The camera (lens.ts) pushes in where a step's action starts and pulls
+ * back with the pointer as it reaches its destination; every position here is
+ * in scene pixels (rect, centre), which the camera does not change.
+ *
* What is not the app itself is drawn here: the pointer, the Ctrl+C keys and
* the other apps (a browser to copy from, File Explorer to drag a file out of,
* a notes app to drop a card into). The drag image is the app's own drag
@@ -16,6 +20,7 @@ import type { ClipboardItemDto } from '../../shared/types'
import { dragGhostSvg } from '../../shared/dragGhost'
import { fileIconUrl, fileKindOf, type FileKind } from '../lib/fileKind'
import { LAPTOP_SCREEN, SHELF_SCALE, TOUR_SCREEN_TOP, toShelfLayer } from './edgeBar'
+import { aim, REST, toLocal, toScreen, zoomRest, zoomTo, type Rect, type View } from './lens'
import {
demoText, demoLink, demoImage, demoPdf, demoStack, demoSingle, demoMerged, STACK_FILES, DEMO_DIR
} from './demoItems'
@@ -43,6 +48,12 @@ export class Run {
)
}
+ /** An animation made elsewhere, stopped with the run. */
+ keep(a: Animation): Animation {
+ this.anims.push(a)
+ return a
+ }
+
cancel(): void {
this.dead = true
this.timers.forEach(clearTimeout)
@@ -62,6 +73,8 @@ export interface Stage {
browser: HTMLElement
/** File Explorer, the drag-in demo's source. */
explorer: HTMLElement
+ /** The camera over all of the above (lens.ts). */
+ lens: HTMLElement
/** Welcome: the real shelf in place of the drawn bar on the laptop (the closed bars match exactly). */
showShelf: (on: boolean) => void
}
@@ -110,9 +123,13 @@ export function resetDemoState(stage: Stage, next?: string): void {
})
setEdgeDragPull(0)
stage.cursor.getAnimations().forEach((a) => a.cancel())
+ document.body.classList.remove('ob-preview-pan')
stage.keys.getAnimations().forEach((a) => a.cancel())
stage.notesImage.getAnimations().forEach((a) => a.cancel())
clearMarks(stage)
+ stage.root.querySelector('.ob-cam')?.classList.remove('is-push')
+ const view = openingView(next)
+ if (view) zoomTo(stage.lens, view, 900)
const keep = next ? WINDOW_OF[next]?.(stage) : undefined
for (const w of [stage.notes, stage.browser, stage.explorer]) if (w !== keep) hideWindow(w)
stage.root.querySelector('.ob-shelf')?.getAnimations().forEach((a) => a.cancel())
@@ -126,29 +143,51 @@ function card(stage: Stage, id: string): HTMLElement {
return el
}
-const centre = (el: Element) => {
- const r = el.getBoundingClientRect()
+/** An element's box in scene pixels. */
+const rect = (stage: Stage, el: Element): Rect => toLocal(stage.lens, el.getBoundingClientRect())
+
+const centre = (stage: Stage, el: Element) => {
+ const r = rect(stage, el)
return { x: r.left + r.width / 2, y: r.top + r.height / 2 }
}
-/** The other apps open with a short rise; a replay finds them already up. Not tied to a run: on a step change they fade out (hideWindow) instead of vanishing. */
+// ---------- the camera's framings (lens.ts) ----------
+
+/** How far the camera pushes in on a window or a card. */
+const PUSH = 1.3
+
+/** The shelf close-up: the whole row of cards, bigger, with the screen's top edge (the bar, its light) in frame. */
+const SHELF_CLOSE: View = aim(1.35, { x: 400, y: 0 }, { x: 400, y: -15 })
+
+/** Pushed in with the screen's top edge kept in frame (the bar, the copy flare), `focusX` staying at `atX`. */
+const withEdge = (k: number, focusX: number, atX = 400): View => aim(k, { x: focusX, y: 0 }, { x: atX, y: -15 })
+
+/** Pushed in on a window, centred in the space above the step's text. */
+const onWindow = (box: Rect): View => aim(PUSH, { x: box.left + box.width / 2, y: box.top + box.height / 2 }, { x: 400, y: 236 })
+
+/**
+ * The framing a step opens on: the shelf close-up for the steps that play on the row of cards (the
+ * camera stays there from one to the next), the whole scene otherwise. Preview keeps what it gets and
+ * pulls back as its pointer comes in (its flyout opens outside the camera, at rest).
+ */
+function openingView(step?: string): View | null {
+ if (step === 'ungroup' || step === 'merge') return SHELF_CLOSE
+ if (step === 'preview') return null
+ return REST
+}
+
+/**
+ * The other apps open with a short rise and close with a fade (a class: .is-up). Not tied to a run: on a
+ * step change they fade out instead of vanishing, and a replay finds them already up. Not a held
+ * animation either: the browser may drop a finished animation nobody references and leave its last
+ * value stuck, which kept a window on screen after its step.
+ */
function showWindow(el: HTMLElement) {
- const now = Number(getComputedStyle(el).opacity)
- if (now > 0.99 && !el.dataset.leaving) return
- el.getAnimations().forEach((a) => a.cancel())
- delete el.dataset.leaving
- el.animate([{ opacity: now, transform: now > 0 ? 'none' : 'translateY(14px) scale(.97)' }, { opacity: 1, transform: 'none' }], {
- duration: 420, easing: 'cubic-bezier(.3,.8,.2,1)', fill: 'forwards'
- })
+ el.classList.add('is-up')
}
function hideWindow(el: HTMLElement) {
- if (!el.getAnimations().length || el.dataset.leaving) return
- const now = getComputedStyle(el).opacity
- el.getAnimations().forEach((a) => a.cancel())
- el.dataset.leaving = '1'
- const a = el.animate([{ opacity: now }, { opacity: 0 }], { duration: 260, easing: 'ease', fill: 'forwards' })
- a.finished.then(() => { if (el.dataset.leaving) { delete el.dataset.leaving; a.cancel() } }).catch(() => {})
+ el.classList.remove('is-up')
}
/** Text selections and the selected file in the other apps (they fade on a rewind). */
@@ -207,7 +246,7 @@ class DragImage {
svg?.setAttribute('width', String(this.w))
svg?.setAttribute('height', String(this.h))
this.el.style.transform = this.tf(at)
- stage.root.append(this.el)
+ stage.lens.append(this.el)
run.animate(this.el, [{ opacity: 0 }, { opacity: 1 }], { duration: 90, fill: 'none' }).catch(() => {})
}
private tf(p: { x: number; y: number }) {
@@ -235,7 +274,7 @@ class FileGhost {
this.el.className = 'ob-ghost ob-file-ghost'
this.el.innerHTML = `<img src="${fileIconUrl(kind)}" alt=""><span>+ Copy</span>`
this.el.style.transform = this.tf(at)
- stage.root.append(this.el)
+ stage.lens.append(this.el)
run.animate(this.el, [{ opacity: 0 }, { opacity: 1 }], { duration: 140, fill: 'none' }).catch(() => {})
}
private tf(p: { x: number; y: number }) {
@@ -254,12 +293,23 @@ class FileGhost {
}
}
-/** Ctrl+C on screen: centred, or (`at`) beside the app being copied from. */
-async function keys(run: Run, stage: Stage, label: string, at?: { x: number; y: number }) {
+/**
+ * Ctrl+C on screen: centred, or beside the window being copied from (`beside`, in scene pixels), as that
+ * window is framed on screen: to its right, or to its left where the right has no room.
+ */
+async function keys(run: Run, stage: Stage, label: string, beside?: Rect) {
stage.keysLabel.textContent = label
- stage.keys.style.left = at ? `${at.x}px` : ''
- stage.keys.style.right = at ? 'auto' : ''
- stage.keys.style.top = at ? `${at.y}px` : ''
+ stage.keys.style.right = beside ? 'auto' : ''
+ stage.keys.style.left = beside ? '0px' : ''
+ stage.keys.style.top = ''
+ if (beside) {
+ const a = toScreen(stage.lens, { x: beside.left, y: beside.top })
+ const b = toScreen(stage.lens, { x: beside.right, y: beside.bottom })
+ const w = stage.keys.offsetWidth
+ const x = b.x + 14 + w <= 792 ? b.x + 14 : a.x - 14 - w
+ stage.keys.style.left = `${Math.round(x)}px`
+ stage.keys.style.top = `${Math.round((a.y + b.y) / 2 - 34)}px`
+ }
await run.animate(stage.keys, [{ opacity: 0, transform: 'translateY(10px) scale(.92)' }, { opacity: 1, transform: 'none' }], { duration: 160 })
await run.sleep(300)
run.animate(stage.keys, [{ opacity: 1, transform: 'none' }, { opacity: 0, transform: 'translateY(-6px)' }], { duration: 200 }).catch(() => {})
@@ -283,18 +333,67 @@ export async function demoWelcome(run: Run, stage: Stage) {
set({ items: itemsFor('welcome'), open: false })
stage.showShelf(true)
await p.show(540, 250)
+ // the camera pushes in on the bar with the pointer; the laptop's lower half (bezel, taskbar, base) fades
+ // as it would run down under the text
+ // (under reduced motion the camera stays put, and so does the laptop)
+ const cam = document.documentElement.dataset.motion === 'reduce' ? null : stage.root.querySelector('.ob-cam')
+ cam?.classList.add('is-push')
+ zoomTo(stage.lens, aim(PUSH, { x: 400, y: LAPTOP_SCREEN.top }, { x: 400, y: 44 }, true), 800, MOVE)
await p.move(400, LAPTOP_SCREEN.top + 3, 800)
set({ open: true })
await run.sleep(1200)
+ zoomRest(stage.lens, 1000)
+ cam?.classList.remove('is-push')
await p.move(520, 330, 650)
set({ open: false })
await run.sleep(400)
await p.hide()
+ await run.sleep(300)
}
/** The selection highlight behind an element (a line of the page, the address). */
const hl = (el: Element) => el.querySelector<HTMLElement>('.ob-hl')!
+/**
+ * A text selection made by dragging, following the pointer frame by frame: a line above the pointer is
+ * selected in full, the line it is on up to the pointer, the lines below not yet.
+ */
+function selectAlong(run: Run, stage: Stage, lines: HTMLElement[], rows: Rect[]) {
+ const bars = lines.map((l) => {
+ const a = run.keep(hl(l).animate([{ transform: 'scaleX(0)' }, { transform: 'scaleX(1)' }], { duration: 1000, fill: 'forwards' }))
+ a.pause()
+ a.currentTime = 0
+ return a
+ })
+ let on = true
+ const frame = () => {
+ if (!on || run.dead) return
+ const m = new DOMMatrixReadOnly(getComputedStyle(stage.cursor).transform)
+ // the arrow's tip (Pointer.tf)
+ const x = m.e + 2
+ const y = m.f + 2
+ rows.forEach((r, i) => {
+ const f = y >= r.bottom ? 1 : y < r.top ? 0 : Math.min(1, Math.max(0, (x - r.left) / r.width))
+ bars[i].currentTime = f * 1000
+ })
+ requestAnimationFrame(frame)
+ }
+ requestAnimationFrame(frame)
+ return {
+ stop() {
+ on = false
+ // the drag ends at the sentence's end: all of it is selected
+ bars.forEach((a) => { a.currentTime = 1000 })
+ }
+ }
+}
+
+/** A selection ends: its highlight goes. */
+function deselect(run: Run, el: HTMLElement) {
+ if (!el.getAnimations().length) return
+ run.animate(el, [{ opacity: 1 }, { opacity: 0 }], { duration: 160, easing: 'ease' }).catch(() => {})
+}
+
/**
* Copy from a web page the way people do, with the shelf closed: select a sentence and press Ctrl+C,
* click the address and press Ctrl+C, right-click the photo and choose Copy image. Each copy lights the
@@ -306,48 +405,50 @@ export async function demoCollect(run: Run, stage: Stage) {
clearMarks(stage)
showWindow(page)
await run.sleep(250)
- const box = page.getBoundingClientRect()
- // Ctrl+C beside the browser, out of the way of what is being copied
- const side = { x: box.right + 18, y: box.top + box.height / 2 - 34 }
+ const box = rect(stage, page)
const now = Date.now()
// 1. a sentence: press at its start and drag to its end, the selection following the pointer line by line
const lines = [...page.querySelectorAll<HTMLElement>('.ob-line')]
- const r0 = lines[0].getBoundingClientRect()
+ const r0 = rect(stage, lines[0])
+ // the camera pushes in on the page as the pointer comes in, the screen's edge (where each copy lights) in frame
+ zoomTo(stage.lens, withEdge(PUSH, box.left + box.width / 2), 1000)
await p.show(box.left + box.width * 0.55, box.bottom - 30)
await p.move(r0.left, r0.top + r0.height / 2, 650)
await p.press()
- for (const [k, line] of lines.entries()) {
- const r = line.getBoundingClientRect()
- const ms = k === 0 ? 520 : 300
- await Promise.all([
- p.move(r.right, r.top + r.height / 2, ms, 'linear'),
- run.animate(hl(line), [{ transform: 'scaleX(0)' }, { transform: 'scaleX(1)' }], { duration: ms, easing: 'linear' })
- ])
- }
+ // drag along the first line, then down to the end of the sentence; the selection is where the pointer is
+ const rows = lines.map((l) => rect(stage, l))
+ const last = rows[rows.length - 1]
+ const selecting = selectAlong(run, stage, lines, rows)
+ await p.move(rows[0].right, rows[0].top + rows[0].height / 2 + 1, 560, 'cubic-bezier(.35,0,.65,1)')
+ await p.move(last.right + 2, last.top + last.height / 2, 520, 'cubic-bezier(.35,0,.25,1)')
+ selecting.stop()
await run.sleep(150)
- await keys(run, stage, '', side)
+ await keys(run, stage, '', box)
capture(demoText(now))
copyFlare(run)
await run.sleep(450)
// 2. the link: a click in the address bar selects it all
const url = page.querySelector<HTMLElement>('.ob-url')!
- const u = url.getBoundingClientRect()
+ const u = rect(stage, url)
await p.move(u.left + u.width * 0.6, u.top + u.height / 2, 600)
await p.press()
+ // a click elsewhere ends the page's selection; the address selects all at once
+ lines.forEach((l) => deselect(run, hl(l)))
run.animate(hl(url), [{ transform: 'scaleX(0)', opacity: 0 }, { transform: 'scaleX(1)', opacity: 1 }], { duration: 140 }).catch(() => {})
await run.sleep(250)
- await keys(run, stage, '', side)
+ await keys(run, stage, '', box)
capture(demoLink(now))
copyFlare(run)
await run.sleep(450)
// 3. the photo: right-click, Copy image
const photo = page.querySelector<HTMLElement>('.ob-photo')!
- const ph = photo.getBoundingClientRect()
+ const ph = rect(stage, photo)
await p.move(ph.left + ph.width * 0.45, ph.top + ph.height * 0.55, 600)
await p.press()
+ deselect(run, hl(url))
const menu = page.querySelector<HTMLElement>('.ob-menu')!
// at the pointer, flipped to the other side where it would not fit in the window (as real menus do)
const mx = ph.left + ph.width * 0.45 - box.left
@@ -360,7 +461,7 @@ export async function demoCollect(run: Run, stage: Stage) {
menu.classList.add('is-open')
await run.sleep(260)
const item = menu.querySelector<HTMLElement>('.is-copy')!
- const it = item.getBoundingClientRect()
+ const it = rect(stage, item)
await p.move(it.left + 34, it.top + it.height / 2, 380)
item.classList.add('is-hover')
await run.sleep(180)
@@ -371,7 +472,8 @@ export async function demoCollect(run: Run, stage: Stage) {
copyFlare(run)
await run.sleep(700)
- // all of it is on the shelf
+ // all of it is on the shelf: the camera pulls back as the pointer rides up, so the shelf opens in full view
+ zoomRest(stage.lens, 750, MOVE)
await p.move(400, TOUR_SCREEN_TOP + 5, 750)
set({ open: true })
await run.sleep(900)
@@ -391,7 +493,9 @@ export async function demoDropIn(run: Run, stage: Stage) {
await run.sleep(250)
const row = win.querySelector<HTMLElement>('.ob-file.is-pdf')!
const icon = row.querySelector('img')!
- const c = centre(icon)
+ const c = centre(stage, icon)
+ const box = rect(stage, win)
+ zoomTo(stage.lens, onWindow(box), 1000)
await p.show(560, 380)
await p.move(c.x, c.y, 650)
row.classList.add('is-on')
@@ -407,6 +511,8 @@ export async function demoDropIn(run: Run, stage: Stage) {
[0.75, 300, 'linear', 0.6],
[1, 360, 'cubic-bezier(0,0,.3,1)', 0.9]
]
+ // the camera pulls back as the file rides up, so the bar swelling and the shelf opening are in full view
+ zoomRest(stage.lens, 1080, MOVE)
for (const [t, ms, easing, pull] of legs) {
const x = from.x + (bar.x - from.x) * t
const y = from.y + (bar.y - from.y) * t
@@ -440,14 +546,18 @@ export async function demoDrag(run: Run, stage: Stage) {
showWindow(stage.notes)
await p.show(600, 400)
const src = card(stage, 'demo-image')
- const c = centre(src)
+ const c = centre(stage, src)
+ zoomTo(stage.lens, withEdge(PUSH, c.x, c.x), 900)
await p.move(c.x, c.y, 700)
await p.press()
set({ internalDragReq: { id: 'demo-image' } })
await p.move(c.x + 6, c.y + 8, 120)
const g = new DragImage(run, stage, ['image'], 1, { x: c.x + 6, y: c.y + 8 })
- // drop where the picture lands in the document
- const { x: tx, y: ty } = centre(stage.notesImage)
+ // drop where the picture lands in the document, the camera following the drag down to it
+ const { x: tx, y: ty } = centre(stage, stage.notesImage)
+ const notes = rect(stage, stage.notes)
+ const nx = notes.left + notes.width / 2
+ zoomTo(stage.lens, aim(PUSH, { x: nx, y: notes.bottom }, { x: nx, y: 430 }), 850, MOVE)
await Promise.all([p.move(tx, ty, 850), g.move(tx, ty, 850)])
g.drop()
set({ internalDragReq: null })
@@ -455,8 +565,10 @@ export async function demoDrag(run: Run, stage: Stage) {
// a card dragged out into another app counts as used: it moves to the front (main: movePastedToTop)
const items = useStore.getState().items
set({ items: [...items.filter((it) => it.id === 'demo-image').map((it) => ({ ...it, capturedAt: Date.now() })), ...items.filter((it) => it.id !== 'demo-image')] })
+ zoomRest(stage.lens, 1000)
await run.sleep(300)
await p.hide()
+ await run.sleep(450)
}
/**
@@ -472,35 +584,38 @@ export async function demoStacks(run: Run, stage: Stage) {
const list = win.querySelector<HTMLElement>('.ob-files')!
const band = list.querySelector<HTMLElement>('.ob-band')!
const rows = [...list.querySelectorAll<HTMLElement>('.ob-file:not(.is-pdf)')]
- const lb = list.getBoundingClientRect()
- const box = win.getBoundingClientRect()
- const top = rows[0].getBoundingClientRect()
- const bottom = rows[rows.length - 1].getBoundingClientRect()
+ const lb = rect(stage, list)
+ const box = rect(stage, win)
+ const top = rect(stage, rows[0])
+ const bottom = rect(stage, rows[rows.length - 1])
// from the empty space under the list, up and to the left across the three files
const from = { x: lb.right - 24, y: bottom.bottom + 14 }
const to = { x: top.left + top.width * 0.42, y: top.top + top.height * 0.5 }
+ zoomTo(stage.lens, onWindow(box), 1000)
await p.show(box.right - 40, box.bottom + 30)
await p.move(from.x, from.y, 600)
await p.press()
const T = 900
- const rect = (x: number, y: number) => ({ left: `${x - lb.left}px`, top: `${y - lb.top}px` })
+ const bandAt = (x: number, y: number) => ({ left: `${x - lb.left}px`, top: `${y - lb.top}px` })
run.animate(band, [
- { ...rect(from.x, from.y), width: '0px', height: '0px', opacity: 1 },
- { ...rect(to.x, to.y), width: `${from.x - to.x}px`, height: `${from.y - to.y}px`, opacity: 1 }
+ { ...bandAt(from.x, from.y), width: '0px', height: '0px', opacity: 1 },
+ { ...bandAt(to.x, to.y), width: `${from.x - to.x}px`, height: `${from.y - to.y}px`, opacity: 1 }
], { duration: T, easing: 'linear' }).catch(() => {})
// each file joins the selection as the box's edge reaches it
for (const row of rows) {
- const reach = (from.y - (row.getBoundingClientRect().bottom - 4)) / (from.y - to.y)
+ const reach = (from.y - (rect(stage, row).bottom - 4)) / (from.y - to.y)
run.sleep(Math.max(0, reach) * T).then(() => row.classList.add('is-on')).catch(() => {})
}
await p.move(to.x, to.y, T, 'linear')
// let go: the box goes, the three stay selected
run.animate(band, [{ opacity: 1 }, { opacity: 0 }], { duration: 160 }).catch(() => {})
await run.sleep(300)
- await keys(run, stage, '', { x: box.right + 18, y: box.top + box.height / 2 - 34 })
+ await keys(run, stage, '', box)
capture(demoStack(Date.now()))
copyFlare(run)
- await run.sleep(600)
+ // the stack lands at the front of the shelf: the camera pulls back to show it there
+ zoomRest(stage.lens, 900)
+ await run.sleep(900)
await p.move(box.right - 40, box.bottom + 30, 600)
await p.hide()
}
@@ -510,7 +625,7 @@ export async function demoUngroup(run: Run, stage: Stage) {
const p = new Pointer(run, stage.cursor)
await p.show(560, 380)
const stackCard = card(stage, 'demo-stack')
- const c = centre(stackCard)
+ const c = centre(stage, stackCard)
await p.move(c.x, c.y, 650)
await p.press()
set({ expandedStackId: 'demo-stack' })
@@ -518,13 +633,14 @@ export async function demoUngroup(run: Run, stage: Stage) {
// The expanded stack's first file row (StackItems).
const tile = stage.root.querySelector<HTMLElement>('.item-main[data-id="demo-stack"] .stack-row')
if (!tile) throw STOP
- const t = centre(tile)
+ const t = centre(stage, tile)
await p.move(t.x, t.y, 500)
await p.press()
const path = DEMO_DIR + STACK_FILES[0][0]
set({ internalDragReq: { id: 'demo-stack', paths: [path] } })
await p.move(t.x + 6, t.y + 8, 120)
const g = new DragImage(run, stage, [fileKindOf(path)], 1, { x: t.x + 6, y: t.y + 8 })
+ // up to the light on the edge (in frame: the close-up keeps the screen's edge)
const ex = 400, ey = TOUR_SCREEN_TOP + 5
await Promise.all([p.move(ex, ey, 900), g.move(ex, ey, 900)])
await run.sleep(500) // the edge light answers the drag
@@ -541,14 +657,14 @@ export async function demoMerge(run: Run, stage: Stage) {
const p = new Pointer(run, stage.cursor)
await p.show(600, 380)
const src = card(stage, 'demo-image')
- const c = centre(src)
+ const c = centre(stage, src)
await p.move(c.x, c.y, 650)
await p.press()
set({ internalDragReq: { id: 'demo-image' } })
await p.move(c.x + 6, c.y + 8, 120)
const g = new DragImage(run, stage, ['image'], 1, { x: c.x + 6, y: c.y + 8 })
const target = card(stage, 'demo-single')
- const tc = centre(target)
+ const tc = centre(stage, target)
await Promise.all([p.move(tc.x, tc.y, 950), g.move(tc.x, tc.y, 950)])
set({ dropTargetId: 'demo-single' })
await run.sleep(450)
@@ -563,26 +679,42 @@ export async function demoMerge(run: Run, stage: Stage) {
await p.hide()
}
-/** Press preview on a card: the flyout opens with the whole stack. */
+/**
+ * How far the camera pans the screen up while the preview is open, so all of it (the app's 460px, at the
+ * shelf's scale: y 179 to 510) is in view above the step's text, which starts at 444 (it ends at 418); .ob-preview-pan moves the flyout (outside the camera)
+ * the same way.
+ */
+export const PREVIEW_PAN = 92
+
+/** Press preview on a stack: the flyout opens with every file in it, and the camera pans up to show all of it. */
export async function demoPreview(run: Run, stage: Stage) {
const p = new Pointer(run, stage.cursor)
await p.show(600, 380)
- const target = card(stage, 'demo-single')
- const c = centre(target)
+ const target = card(stage, 'demo-stack')
+ const c = centre(stage, target)
+ document.body.classList.remove('ob-preview-pan')
+ zoomRest(stage.lens, 900)
await p.move(c.x, c.y, 650)
target.classList.add('force-actions')
await run.sleep(250)
const btn = target.querySelector<HTMLElement>('.act.preview-expand')
if (btn) {
- const b = centre(btn)
+ const b = centre(stage, btn)
await p.move(b.x, b.y, 380)
}
await p.press()
const r = target.getBoundingClientRect()
- set({ previewItemId: 'demo-single', previewItemRect: toShelfLayer(r) })
- await run.sleep(500)
+ set({ previewItemId: 'demo-stack', previewItemRect: toShelfLayer(r) })
+ await run.sleep(450)
target.classList.remove('force-actions')
await p.hide()
+ // the camera pans the screen up so the whole preview is in view, and stays there while the step is up
+ // (a replay or the next step brings it back)
+ if (document.documentElement.dataset.motion !== 'reduce') {
+ document.body.classList.add('ob-preview-pan')
+ zoomTo(stage.lens, { k: 1, x: 0, y: -PREVIEW_PAN }, 750)
+ await run.sleep(800)
+ }
}
export const DEMOS: Record<string, ((run: Run, stage: Stage) => Promise<void>) | undefined> = {
@@ -627,10 +759,20 @@ const shelfLayer = (stage: Stage) => stage.root.querySelector<HTMLElement>('.ob-
async function rewind(run: Run, stage: Stage, step: string, open: boolean) {
const st = useStore.getState()
set({ previewItemId: null, previewItemRect: null, expandedStackId: null })
+ // a preview's pan comes back down as the preview closes
+ if (document.body.classList.contains('ob-preview-pan')) {
+ document.body.classList.remove('ob-preview-pan')
+ zoomRest(stage.lens, 750)
+ }
for (const m of marks(stage)) {
if (!m.getAnimations().length) continue
+ // from where it is (a selection already ended stays gone)
+ const cs = getComputedStyle(m)
+ const o = Number(cs.opacity)
+ const t = cs.transform === 'none' ? 'scaleX(0)' : cs.transform
m.getAnimations().forEach((a) => a.cancel())
- run.animate(m, [{ transform: 'scaleX(1)', opacity: 1 }, { transform: 'scaleX(1)', opacity: 0 }], { duration: 400, easing: 'ease' }).catch(() => {})
+ if (o < 0.01) continue
+ run.animate(m, [{ transform: t, opacity: o }, { transform: t, opacity: 0 }], { duration: 400, easing: 'ease' }).catch(() => {})
}
stage.root.querySelectorAll('.ob-file.is-on').forEach((el) => el.classList.remove('is-on'))
if (stage.notesImage.getAnimations().length) {
diff --git a/src/styles/item.css b/src/styles/item.css
index 561b216..2eccd16 100644
--- a/src/styles/item.css
+++ b/src/styles/item.css
@@ -1454,6 +1454,21 @@ html[data-motion='reduce'] .file-stack-folder {
the group keeps its top margin. */
/* ...and in any file stack its hover swing lifts 4px less, so its corner
stays clear of the card's top edge. */
+/* A photo in a file stack takes its place in the stack's order like the folders do: the photo cards'
+ own z-indexes (2 and 1 in a pair) sat below the folders' (4 down to 1), so a dimmed back folder was
+ drawn over the front photo. */
+.image-folder-stack-deck.is-file-deck .image-folder-stack-item.pos-0 {
+ z-index: 4;
+}
+.image-folder-stack-deck.is-file-deck .image-folder-stack-item.pos-1 {
+ z-index: 3;
+}
+.image-folder-stack-deck.is-file-deck .image-folder-stack-item.pos-2 {
+ z-index: 2;
+}
+.image-folder-stack-deck.is-file-deck .image-folder-stack-item.pos-3 {
+ z-index: 1;
+}
.image-folder-stack-deck.is-file-deck .image-folder-stack-item {
transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), translate 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, opacity 0.28s ease;
}
diff --git a/src/styles/onboarding.css b/src/styles/onboarding.css
index 5d51314..8ec43fa 100644
--- a/src/styles/onboarding.css
+++ b/src/styles/onboarding.css
@@ -27,6 +27,22 @@
transform: none;
transition: transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}
+/* The camera over the scene (lens.ts sets its transform and transition per move, and CSS zoom while it
+ holds). A fixed size, not inset: under zoom the scene inside must keep its 800 x 640 layout. No
+ will-change: it would keep the layer drawn at its unzoomed size and stretch it. */
+.ob-lens {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 800px;
+ height: 640px;
+ transform-origin: 0 0;
+}
+[data-motion='reduce'] .ob-lens {
+ transform: none !important;
+ transition: none !important;
+ zoom: 1 !important;
+}
.ob-sky {
position: absolute;
left: 0;
@@ -49,8 +65,53 @@
transform-origin: 50% 0;
transition: transform 0.9s cubic-bezier(0.3, 0.7, 0.2, 1);
/* The layer stands for the screen: what Panel draws past its edges (the copy tab's part behind the
- edge) is off-screen in the app, so it must not show above the laptop's screen here. */
+ edge) is off-screen in the app, so it must not show above the laptop's screen here. The margin lets
+ the backing below (and that part of the tab) reach behind the bezel, which covers it. */
overflow: clip;
+ overflow-clip-margin: 6px;
+}
+/* The bezel and the shelf are separate layers: wherever the camera, or a fractional display scale,
+ leaves the screen's top edge between pixels, each covers only part of that row of pixels, and the
+ wallpaper behind showed through as a blue line between them. So both get a dark backing at the edge:
+ the shelf's black carries on a little way up behind the bezel (::before), and under the shelf's own
+ first rows, the width of the bar or of the open shelf (::after; black on black, never seen), so the
+ row blends with black, never with sky. */
+.ob-shelf::before {
+ content: '';
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: -6px;
+ height: 6px;
+ background: #000;
+}
+.ob-shelf::after {
+ content: '';
+ position: absolute;
+ /* across the edge, overlapping ::before: no soft edge of either falls on the edge's row */
+ top: -2px;
+ left: 50%;
+ width: var(--ob-bar-w);
+ height: 4px;
+ transform: translateX(-50%);
+ background: #000;
+}
+/* the open shelf: the dock's width (Panel: the window's width less 60px) */
+.ob-shelf.is-open::after {
+ width: calc(100% - 60px);
+}
+/* The cards' pictures (file icons, the folders and photos of a stack, the grain) are each kept on a
+ pre-drawn layer in the app, sharp there because the shelf is shown 1:1 (item.css). Here the shelf is
+ shown scaled (0.72, and the camera zooms it), so those layers were resampled and the glass folders read
+ as a milky smear; in the tour they are drawn at the size they are shown. */
+.ob-shelf .single-file-hero svg,
+.ob-shelf .single-file-hero img.file-kind-img,
+.ob-shelf .file-kind-opening > .fko-plain,
+.ob-shelf .fko-layers > .fil,
+.ob-shelf .image-folder-stack-item,
+.ob-shelf .file-stack-folder,
+.ob-shelf .is-textured::before {
+ will-change: auto !important;
}
.ob-shelf .root {
position: absolute;
@@ -64,6 +125,24 @@
margin-left: calc(400px * (1 - var(--ob-shelf-scale)) / var(--ob-shelf-scale));
margin-top: calc(var(--ob-shelf-top) / var(--ob-shelf-scale));
}
+/* Preview step: the flyout can reach nearly to the window's bottom (the app's 460px), where the step's
+ text is. The text keeps its place, as on every step (top 444); the flyout's last stretch (its file list
+ carries on below, as in a scrolled list) fades out just above it instead of running under it: gone by
+ y 434 even at the flyout's full height. The fade is a gradient sized to 77% of the flyout (nothing shows
+ past it), so it can give way smoothly: while the camera pans
+ the screen up (.ob-preview-pan, PREVIEW_PAN in tour.ts) the flyout moves up with it (translate: in its
+ own zoomed pixels, hence / scale) and the fade's size grows past the bottom, so all of it is in view. */
+.ob-tour.ob-preview-step > .pf-wrap {
+ mask-image: linear-gradient(to bottom, #000 86%, transparent);
+ mask-size: 100% 77%;
+ mask-repeat: no-repeat;
+ translate: 0 0;
+ transition: mask-size 0.75s cubic-bezier(0.5, 0, 0.25, 1), translate 0.75s cubic-bezier(0.5, 0, 0.25, 1);
+}
+.ob-tour.ob-preview-step.ob-preview-pan > .pf-wrap {
+ mask-size: 100% 130%;
+ translate: 0 calc(var(--ob-preview-pan) / var(--ob-shelf-scale));
+}
/* Hidden with opacity, not visibility: parts of Panel set visibility inline, which would show through. */
.ob-shelf.is-hidden {
opacity: 0;
@@ -116,6 +195,17 @@
.ob-cam.is-tour .ob-base {
opacity: 0;
}
+/* Welcome: the camera pushes in on the bar, and the laptop's lower half (bezel, taskbar, base) fades as
+ it would run down under the step's text. */
+.ob-cam.is-push .ob-bezel {
+ mask-size: 100% 420px;
+ box-shadow: none;
+}
+.ob-cam.is-push .ob-base,
+.ob-cam.is-push .ob-taskbar.is-on {
+ opacity: 0;
+ transition: opacity 0.4s ease;
+}
.ob-cam.is-close.is-top {
transform-origin: 400px 10px;
transform: scale(1.04);
@@ -476,9 +566,9 @@
}
.ob-explorer {
left: 196px;
- top: 172px;
+ top: 166px;
width: 330px;
- height: 222px;
+ height: 260px;
}
.ob-explorer .ob-win-bar {
padding-left: 12px;
@@ -519,7 +609,7 @@
}
.ob-file {
grid-template-columns: 22px 1fr 64px;
- height: 30px;
+ height: 27px;
border-radius: 5px;
transition: background 0.2s;
}
@@ -538,6 +628,23 @@
background: rgba(51, 144, 255, 0.28);
}
+/* The other apps' windows: up (is-up, tour.ts showWindow) with a short rise, gone with a fade. */
+.ob-win,
+.ob-notes {
+ transition: opacity 0.26s ease;
+}
+.ob-win.is-up,
+.ob-notes.is-up {
+ opacity: 1;
+ animation: ob-win-rise 0.42s cubic-bezier(0.3, 0.8, 0.2, 1);
+}
+@keyframes ob-win-rise {
+ from {
+ opacity: 0;
+ transform: translateY(14px) scale(0.97);
+ }
+}
+
.ob-keys {
position: absolute;
left: 0;
@@ -582,7 +689,7 @@
display: block;
}
.ob-ghost {
- position: fixed;
+ position: absolute;
left: 0;
top: 0;
z-index: 25;
@@ -637,30 +744,6 @@
top: auto;
bottom: 16px;
}
-/* Preview step: the flyout opens under the shelf on the left, so the text moves to the right. */
-.ob-ui.is-side {
- left: 500px;
- right: 40px;
- top: 300px;
-}
-/* The side text sits over the brightest clouds: a soft deep-blue pool behind it, the same tint as under
- the centred text (a gradient, no blur). */
-.ob-ui.is-side {
- isolation: isolate;
-}
-.ob-ui.is-side::before {
- content: '';
- position: absolute;
- inset: -70px -60px -70px -80px;
- z-index: -1;
- pointer-events: none;
- background: radial-gradient(closest-side, rgba(6, 16, 110, 0.62), rgba(6, 16, 110, 0.38) 55%, rgba(6, 16, 110, 0));
-}
-.ob-ui.is-side .ob-copy,
-.ob-ui.is-side .ob-copy p {
- align-items: flex-start;
- text-align: left;
-}
.ob-dots {
display: flex;
gap: 5px;