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.
TypeScript clipboardclipboard-managerdesktop-appdrag-and-dropelectronopen-sourceproductivityproductivity-toolwindows
feat(motion): spring-based shelf open/close with content veil
Deepender25d6035ea2c32f
diff --git a/src/components/Panel.tsx b/src/components/Panel.tsxindex bf06f07..7cbea0d 100644--- a/src/components/Panel.tsx+++ b/src/components/Panel.tsx@@ -1,11 +1,11 @@/**- * Panel — the blade that grows out of the left edge.+ * Panel — the blade that grows out of the screen edge.*- * Motion: when `open` flips true the blade slides in from x = -100% (fully off- * the left edge) to x = 0 with a spring, and its opacity/blur animate together- * for the "extending from the screen" feel. A faint ambient glow leads the- * edge. When closed, the whole blade sits off-screen so the window stays- * transparent and click-through.+ * Motion: when closed, a clip-path leaves only the thin edge bar visible.+ * When `open` flips true the clip springs out to the full blade, growing+ * outward and along the edge together, while a black veil over the content+ * fades away just behind it (see `.blade::after` in panel.css). Closing runs+ * the reverse: the content dims first and the shape draws back into the bar.*/import { motion, AnimatePresence } from 'framer-motion'import { useEffect, useRef, useState, useMemo } from 'react'@@ -26,6 +26,19 @@ import { useFilteredItems } from '../hooks/useFilteredItems'import { useTranslation } from '../i18n'+// Shelf open/close motion: real damped springs written out as CSS linear()+// easings, so the browser runs them with no per-frame JS.+// - Open: response 0.38s, damping 0.86, launched with a little initial+// velocity so the very first frame already moves. It is cut where the+// spring first reaches its target; the overshoot after that point would sit+// outside the blade and be clipped away, so it would only cost frames.+// - Close: critically damped (no bounce), response 0.24s, cut once less than+// a pixel of travel is left. Dismissal is quicker than presentation.+const SHELF_OPEN_MOTION =+ 'clip-path 285ms linear(0, 0.055 3.5%, 0.149 8.5%, 0.414 21.8%, 0.524 27.8%, 0.614 33.3%, 0.693 38.8%, 0.759 44.3%, 0.817 50%, 0.866 56%, 0.907 62.5%, 0.941 69.8%, 0.969 78.3%, 0.989 88.5%, 1)'+const SHELF_CLOSE_MOTION =+ 'clip-path 289ms linear(0, 0.021 1.8%, 0.058 3.8%, 0.116 6.3%, 0.23 10.5%, 0.402 16.8%, 0.503 20.8%, 0.586 24.5%, 0.659 28.2%, 0.725 32.3%, 0.782 36.5%, 0.832 41%, 0.874 46%, 0.911 51.7%, 0.941 58.5%, 0.965 66.8%, 0.982 77.5%, 0.994 93.8%, 1)'+export function Panel() {const open = useStore((s) => s.open)const { pinned, recent } = useFilteredItems()@@ -242,18 +255,19 @@ export function Panel() {if (isTransitioning) containerClass += ' is-transitioning'const reduceMotion = !!settings.reduceMotion- // Single Apple-like reveal curve (no overshoot branch — bounce was dead- // code with no UI surface; the expo ease settles without ringing).+ if (reduceMotion) containerClass += ' reduce-motion'+ // The transition is read from the new style, so picking it by the target+ // state gives the open spring on open and the close spring on close.const clipTransition = reduceMotion? 'clip-path 0.01s linear'- : 'clip-path 0.32s cubic-bezier(0.22, 1, 0.36, 1)'+ : isVisuallyOpen ? SHELF_OPEN_MOTION : SHELF_CLOSE_MOTIONlet currentTransition = clipTransitionlet currentOpacity = 1if (isTransitioning && !reduceMotion) {if (edgeTransition.stage === 'retracting') {- currentTransition = 'clip-path 0.26s cubic-bezier(0.22, 1, 0.36, 1)'+ currentTransition = SHELF_CLOSE_MOTIONcurrentOpacity = 1} else if (edgeTransition.stage === 'bar_fade_out') {currentTransition = 'opacity 0.10s ease-out'@@ -262,7 +276,7 @@ export function Panel() {currentTransition = 'opacity 0.12s ease-out'currentOpacity = 1} else if (edgeTransition.stage === 'expanding') {- currentTransition = 'clip-path 0.30s cubic-bezier(0.16, 1, 0.3, 1)'+ currentTransition = SHELF_OPEN_MOTIONcurrentOpacity = 1}}@@ -323,19 +337,24 @@ export function Panel() {// Set clipPath via style (not animate) to avoid Framer Motion's broken// calc() interpolation — CSS transitions handle it correctly.+ // The open clip is the blade's own box plus the 30px reverse-curve flares,+ // nothing more (flyouts are portaled to <body>, and the blade clips its+ // own overflow). With no spare margin the shape grows outward and along+ // the edge together, instead of the outward edge snapping across in the+ // first frames. Every dock keeps the same 24px corners while it grows.let clipPath: stringconst hotWidth = settings.hotZoneWidth || 3if (isRight) {clipPath = isVisuallyOpen- ? 'inset(calc(0% - 100px) 0px calc(0% - 100px) calc(0% - 800px) round 24px 0px 0px 24px)'+ ? 'inset(-30px 0px -30px 0px round 24px 0px 0px 24px)': `inset(${insetTop} 0px ${insetBottom} calc(100% - ${hotWidth}px) round 24px 0px 0px 24px)`} else if (isTop) {clipPath = isVisuallyOpen- ? 'inset(0px calc(0% - 100px) calc(0% - 600px) calc(0% - 100px) round 0px 0px 24px 24px)'- : `inset(0px ${insetRight} calc(100% - ${hotWidth}px) ${insetLeft} round 0px 0px 999px 999px)`+ ? 'inset(0px -30px 0px -30px round 0px 0px 24px 24px)'+ : `inset(0px ${insetRight} calc(100% - ${hotWidth}px) ${insetLeft} round 0px 0px 24px 24px)`} else {clipPath = isVisuallyOpen- ? 'inset(calc(0% - 100px) calc(0% - 800px) calc(0% - 100px) 0px round 0px 24px 24px 0px)'+ ? 'inset(-30px 0px -30px 0px round 0px 24px 24px 0px)': `inset(${insetTop} calc(100% - ${hotWidth}px) ${insetBottom} 0px round 0px 24px 24px 0px)`}containerStyle.clipPath = clipPathdiff --git a/src/styles/panel.css b/src/styles/panel.cssindex 48146cc..ea5be20 100644--- a/src/styles/panel.css+++ b/src/styles/panel.css@@ -167,6 +167,34 @@display: block;}+/* Content veil. The blade is pure black, so fading a black layer away over+ the content looks exactly like fading the content in, without lifting the+ whole content tree into its own layer. Open: the shape leads and the+ content follows 50ms behind it. Close: the content dims first, then the+ shape draws back into the edge bar. background-color (not opacity) was+ measured to keep CPU and memory at or below the old reveal. Once the close+ has finished (300ms) the veil is hidden, so the resting edge bar is drawn+ exactly as before; on open it is visible again from the first frame. */+.blade::after {+ content: '';+ position: absolute;+ inset: 0;+ z-index: 400; /* above every layer inside the blade (ClearMenu menu is 350) */+ pointer-events: none;+ background-color: rgba(0, 0, 0, 1);+ visibility: hidden;+ transition: background-color 120ms cubic-bezier(0.4, 0, 1, 1), visibility 0s linear 300ms;+}+.blade-container.is-open .blade::after {+ background-color: rgba(0, 0, 0, 0);+ visibility: visible;+ transition: background-color 240ms cubic-bezier(0.2, 0, 0, 1) 50ms, visibility 0s linear 0s;+}+.blade-container.reduce-motion .blade::after {+ transition-duration: 0.01s;+ transition-delay: 0s;+}+/* Header */diff --git a/tests/shelfMotion.test.ts b/tests/shelfMotion.test.tsnew file mode 100644index 0000000..167e033--- /dev/null+++ b/tests/shelfMotion.test.ts@@ -0,0 +1,90 @@+import { describe, expect, it } from 'vitest'+import { readFileSync } from 'node:fs'+import { join } from 'node:path'++const read = (p: string) => readFileSync(join(__dirname, '..', p), 'utf8')+const panel = read('src/components/Panel.tsx')+const css = read('src/styles/panel.css')++function motion(name: string): { ms: number; points: Array<[number, number]> } {+ const m = panel.match(new RegExp(`const ${name} =\\s*'clip-path (\\d+)ms linear\\(([^)]*)\\)'`))+ if (!m) throw new Error(`${name} not found`)+ const parts = m[2].split(',').map((s) => s.trim())+ const points = parts.map((p, i): [number, number] => {+ const [v, pct] = p.split(/\s+/)+ return [Number(v), pct ? Number(pct.replace('%', '')) / 100 : i === 0 ? 0 : 1]+ })+ return { ms: Number(m[1]), points }+}++// Spring step response with initial velocity v0 (SwiftUI-style response / damping).+function spring(t: number, response: number, damping: number, v0: number): number {+ const w0 = (2 * Math.PI) / response+ if (damping >= 1) return 1 - Math.exp(-w0 * t) * (1 + (w0 - v0) * t)+ const wd = w0 * Math.sqrt(1 - damping * damping)+ const a = damping * w0+ return 1 - Math.exp(-a * t) * (Math.cos(wd * t) + ((a - v0) / wd) * Math.sin(wd * t))+}++describe('shelf open/close motion', () => {+ const open = motion('SHELF_OPEN_MOTION')+ const close = motion('SHELF_CLOSE_MOTION')++ it('both curves run 0 -> 1, monotonic, never past the target', () => {+ for (const { points } of [open, close]) {+ expect(points[0]).toEqual([0, 0])+ expect(points[points.length - 1]).toEqual([1, 1])+ for (let i = 1; i < points.length; i++) {+ expect(points[i][0]).toBeGreaterThanOrEqual(points[i - 1][0])+ expect(points[i][1]).toBeGreaterThan(points[i - 1][1])+ expect(points[i][0]).toBeLessThanOrEqual(1)+ }+ }+ })++ it('open follows the 0.38s / 0.86 spring (v0 = 5) and ends where it first reaches the target', () => {+ for (const [v, p] of open.points.slice(1, -1)) {+ expect(Math.abs(spring((p * open.ms) / 1000, 0.38, 0.86, 5) - v)).toBeLessThan(0.003)+ }+ expect(spring(open.ms / 1000, 0.38, 0.86, 5)).toBeGreaterThanOrEqual(0.999)+ })++ it('close follows the critically damped 0.24s spring (v0 = 3) and is under a pixel from done', () => {+ for (const [v, p] of close.points.slice(1, -1)) {+ expect(Math.abs(spring((p * close.ms) / 1000, 0.24, 1, 3) - v)).toBeLessThan(0.003)+ }+ expect(1 - spring(close.ms / 1000, 0.24, 1, 3)).toBeLessThan(0.004)+ })++ it('opens with the open spring, closes with the close spring, edge moves included', () => {+ expect(panel).toContain(': isVisuallyOpen ? SHELF_OPEN_MOTION : SHELF_CLOSE_MOTION')+ expect(panel).toMatch(/stage === 'retracting'\) \{\s*currentTransition = SHELF_CLOSE_MOTION/)+ expect(panel).toMatch(/stage === 'expanding'\) \{\s*currentTransition = SHELF_OPEN_MOTION/)+ // The edge-move sequence waits 300ms for the expand step; the open spring must fit.+ expect(open.ms).toBeLessThanOrEqual(300)+ })++ it('open clip is the blade plus the 30px flares, with no spare margin to snap across', () => {+ expect(panel).toContain("'inset(-30px 0px -30px 0px round 0px 24px 24px 0px)'")+ expect(panel).toContain("'inset(-30px 0px -30px 0px round 24px 0px 0px 24px)'")+ expect(panel).toContain("'inset(0px -30px 0px -30px round 0px 0px 24px 24px)'")+ const insets = panel.match(/inset\([^)']*\)/g) ?? []+ expect(insets.length).toBeGreaterThanOrEqual(6)+ for (const clip of insets) expect(clip).not.toMatch(/800px|600px|999px|- 100px/)+ // The top dock's closed bar uses the same 24px corners as the side docks.+ expect(panel).toContain('calc(100% - ${hotWidth}px) ${insetLeft} round 0px 0px 24px 24px)`')+ })++ it('content veil sits above every in-blade layer and hides only after the close finishes', () => {+ const veil = css.match(/\.blade::after \{([^}]*)\}/)?.[1] ?? ''+ expect(veil).toContain('z-index: 400;')+ expect(veil).toContain('pointer-events: none;')+ expect(veil).toContain('background-color: rgba(0, 0, 0, 1);')+ const hideDelay = Number(veil.match(/visibility 0s linear (\d+)ms/)?.[1])+ expect(hideDelay).toBeGreaterThanOrEqual(close.ms)+ expect(css).toMatch(/\.blade-container\.is-open \.blade::after \{[^}]*background-color: rgba\(0, 0, 0, 0\);[^}]*visibility: visible;/)+ expect(css).toMatch(/\.blade-container\.reduce-motion \.blade::after \{[^}]*transition-duration: 0\.01s;/)+ // Highest z-index used inside the blade (ClearMenu dropdown) stays below the veil.+ expect(read('src/components/ClearMenu.tsx')).toContain('zIndex: 350')+ })+})