gooee 0.48.0 → 0.50.0
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/package.json +1 -1
- package/src/components/HoldToConfirm/HoldToConfirm.tsx +2 -1
- package/src/components/LivePill/LivePill.tsx +1 -1
- package/src/internal/fling.ts +29 -106
- package/src/internal/focus.ts +2 -34
- package/src/internal/liquid.ts +26 -213
- package/src/internal/liquidMatter.ts +9 -181
- package/src/internal/liquidMore.ts +6 -669
- package/src/internal/motion/fling.ts +147 -0
- package/src/internal/motion/focus.ts +35 -0
- package/src/internal/motion/index.ts +20 -0
- package/src/internal/motion/liquid.ts +241 -0
- package/src/internal/motion/liquidMatter.ts +198 -0
- package/src/internal/motion/liquidMore.ts +676 -0
- package/src/internal/motion/scrollFrame.ts +152 -0
- package/src/internal/motion/scrubber.ts +154 -0
- package/src/internal/motion/softPress.ts +334 -0
- package/src/internal/scrollFrame.ts +4 -145
- package/src/internal/softPress.ts +27 -289
- package/src/internal/useScrub.ts +14 -107
|
@@ -1,686 +1,23 @@
|
|
|
1
1
|
import { useEffect, type RefObject } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
import { frames, layer, morphEase, motionFor } from './liquidMatter'
|
|
2
|
+
import { bead, edgeFlow } from './motion/liquidMore'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
// drop that fills the icon and turns into the check) and the menus (a bead that follows the pointer).
|
|
7
|
-
// Same contract as liquidMatter.ts: the SVG exists only while the part moves, and its last frame is
|
|
8
|
-
// the part's own CSS shape.
|
|
4
|
+
export { type Cup, cupLevel, cupPath, type Pour, pour, edgeLoops, type CheckMorph, checkLoops, type CopyState, copyRun, type CopyRun, beadLoops } from './motion/liquidMore'
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
let ids = 0
|
|
12
|
-
|
|
13
|
-
function clipOf(svg: SVGSVGElement) {
|
|
14
|
-
const defs = svg.insertBefore(document.createElementNS(NS, 'defs'), svg.firstChild)
|
|
15
|
-
const clip = defs.appendChild(document.createElementNS(NS, 'clipPath'))
|
|
16
|
-
clip.id = `gooee-liquid-clip-${++ids}`
|
|
17
|
-
const path = clip.appendChild(document.createElementNS(NS, 'path'))
|
|
18
|
-
return { path, url: `url(#${clip.id})` }
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// ---------- cup ----------
|
|
22
|
-
|
|
23
|
-
/** A container's inner walls, floor and rim, and how much the surface tips and curves. */
|
|
24
|
-
export type Cup = { x0: number; x1: number; top: number; bot: number; tilt: number; men: number }
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The surface at fill `f` (0 on the floor, 1 over the rim), poured from side `s` (-1 left, 1 right,
|
|
28
|
-
* 0 evenly from below): high on the poured side at first, then it rises and levels, with a meniscus.
|
|
29
|
-
*/
|
|
30
|
-
export function cupLevel(f: number, s: number, cup: Cup) {
|
|
31
|
-
const cx = (cup.x0 + cup.x1) / 2
|
|
32
|
-
const hw = (cup.x1 - cup.x0) / 2
|
|
33
|
-
const T = cup.tilt * (1 - f) * (1 - f)
|
|
34
|
-
const M = cup.men * (0.4 + 0.6 * (1 - f))
|
|
35
|
-
const L = lerp(cup.bot + cup.tilt * Math.abs(s) + cup.men, cup.top - 1, f)
|
|
36
|
-
return (x: number) => {
|
|
37
|
-
const q = (x - cx) / hw
|
|
38
|
-
return L - s * T * q - M * q * q
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** The liquid under `y` from x0 to x1, closed along `floor`. */
|
|
43
|
-
export function cupPath(y: (x: number) => number, x0: number, x1: number, floor: number) {
|
|
44
|
-
const pts: Pt[] = []
|
|
45
|
-
for (let x = x0; x <= x1 + 1e-6; x += 0.5) pts.push([x, y(x)])
|
|
46
|
-
pts.push([x1, floor], [x0, floor])
|
|
47
|
-
return polyPath(pts)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const cupAttr = (c: Cup) => `${c.x0} ${c.x1} ${c.top} ${c.bot}`
|
|
51
|
-
|
|
52
|
-
// ---------- Checkbox ----------
|
|
53
|
-
|
|
54
|
-
export type Pour = { u: number; side: number; done: boolean; stop: () => void }
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Checkbox: ink pours into `box` from `side` (the side tapped; 0 fills evenly from below), rises with
|
|
58
|
-
* a meniscus and levels, then `mark` draws. Emptying runs it back. While it pours the box carries
|
|
59
|
-
* data-pouring, so its CSS fill stands down. A pour caught half way turns from where it is.
|
|
60
|
-
*/
|
|
61
|
-
export function pour(box: HTMLElement, mark: SVGPathElement | null, to: 0 | 1, side: number, cls: string, prev: Pour | null): Pour | null {
|
|
62
|
-
const live = prev && !prev.done ? (prev as Pour & { svg?: SVGSVGElement; halt?: () => void }) : null
|
|
63
|
-
const from = live ? live.u : 1 - to
|
|
64
|
-
live?.halt?.()
|
|
65
|
-
const ms = motionFor('slow') * Math.abs(to - from)
|
|
66
|
-
if (!ms) {
|
|
67
|
-
live?.stop()
|
|
68
|
-
return null
|
|
69
|
-
}
|
|
70
|
-
// A run caught half way may hand over to the other mark (tick or dash): the old one rests.
|
|
71
|
-
box.querySelectorAll<SVGElement>('[data-mark]').forEach((m) => m !== mark && m.style.removeProperty('stroke-dashoffset'))
|
|
72
|
-
const W = box.offsetWidth
|
|
73
|
-
const bw = box.clientLeft
|
|
74
|
-
const look = getComputedStyle(box)
|
|
75
|
-
const r = parseFloat(look.borderTopLeftRadius) || 0
|
|
76
|
-
const fill = box.querySelector<HTMLElement>('[data-pour-fill]')
|
|
77
|
-
const outer = boxPath({ cx: W / 2, cy: W / 2, hw: W / 2, hh: W / 2, r })
|
|
78
|
-
const inner = W - 2 * bw
|
|
79
|
-
const cup: Cup = { x0: bw, x1: W - bw, top: bw, bot: W - bw, tilt: inner / 3, men: inner / 9 }
|
|
80
|
-
let svg = live?.svg
|
|
81
|
-
let liquid: SVGPathElement
|
|
82
|
-
let clipUrl: string
|
|
83
|
-
if (svg) {
|
|
84
|
-
liquid = svg.querySelector('path[data-measure]')!
|
|
85
|
-
clipUrl = liquid.getAttribute('clip-path') ?? ''
|
|
86
|
-
} else {
|
|
87
|
-
const l = layer(box, cls, box.firstChild)
|
|
88
|
-
svg = l.svg
|
|
89
|
-
liquid = l.paths[0]
|
|
90
|
-
const clip = clipOf(svg)
|
|
91
|
-
clip.path.setAttribute('d', outer)
|
|
92
|
-
clipUrl = clip.url
|
|
93
|
-
svg.setAttribute('width', `${W}`)
|
|
94
|
-
svg.setAttribute('height', `${W}`)
|
|
95
|
-
svg.style.left = svg.style.top = `${-bw}px`
|
|
96
|
-
liquid.style.fill = fill ? getComputedStyle(fill).backgroundColor : 'currentColor'
|
|
97
|
-
liquid.setAttribute('data-measure', 'surface')
|
|
98
|
-
liquid.setAttribute('data-cup', cupAttr(cup))
|
|
99
|
-
}
|
|
100
|
-
box.dataset.pouring = ''
|
|
101
|
-
const e = morphEase()
|
|
102
|
-
const s = live ? live.side : side
|
|
103
|
-
const layerSvg = svg
|
|
104
|
-
const run = {
|
|
105
|
-
u: from,
|
|
106
|
-
side: s,
|
|
107
|
-
done: false,
|
|
108
|
-
svg: layerSvg,
|
|
109
|
-
halt: () => {},
|
|
110
|
-
stop: () => {
|
|
111
|
-
run.done = true
|
|
112
|
-
run.halt()
|
|
113
|
-
layerSvg.remove()
|
|
114
|
-
box.querySelectorAll<SVGElement>('[data-mark]').forEach((m) => m.style.removeProperty('stroke-dashoffset'))
|
|
115
|
-
delete box.dataset.pouring
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
const draw = (p: number) => {
|
|
119
|
-
run.u = lerp(from, to, e(p))
|
|
120
|
-
const f = seg(run.u, 0, 0.78)
|
|
121
|
-
const cp = seg(run.u, 0.7, 1)
|
|
122
|
-
mark?.style.setProperty('stroke-dashoffset', `${1.01 * (1 - cp)}`)
|
|
123
|
-
if (p >= 1) {
|
|
124
|
-
liquid.removeAttribute('clip-path')
|
|
125
|
-
liquid.setAttribute('d', to ? outer : '')
|
|
126
|
-
return
|
|
127
|
-
}
|
|
128
|
-
liquid.setAttribute('clip-path', clipUrl)
|
|
129
|
-
liquid.setAttribute('d', f > 0 ? cupPath(cupLevel(f, s, cup), -1, W + 1, W + 2) : '')
|
|
130
|
-
}
|
|
131
|
-
run.halt = frames(ms, draw, () => run.stop())
|
|
132
|
-
return run
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ---------- field edge ----------
|
|
136
|
-
|
|
137
|
-
type Ring = Array<[number, number, number, number]>
|
|
138
|
-
|
|
139
|
-
function ringLength(cl: Ring) {
|
|
140
|
-
let len = 0
|
|
141
|
-
for (let i = 0; i < cl.length; i++) {
|
|
142
|
-
const a = cl[i]
|
|
143
|
-
const b = cl[(i + 1) % cl.length]
|
|
144
|
-
len += Math.hypot(b[0] - a[0], b[1] - a[1])
|
|
145
|
-
}
|
|
146
|
-
return len
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The edge at progress `e` (0 to 1): two heads run both ways round the centre line `cl` from `i0`, a
|
|
151
|
-
* little fuller than the edge, and meet on the far side; the joined bump then relaxes into the ring.
|
|
152
|
-
*/
|
|
153
|
-
export function edgeLoops(cl: Ring, i0: number, e: number, band: number, head = 1.2, over = 10): Pt[][] {
|
|
154
|
-
const N = cl.length
|
|
155
|
-
const P = ringLength(cl)
|
|
156
|
-
const ds = P / N
|
|
157
|
-
const at = (i: number) => cl[((i % N) + N) % N]
|
|
158
|
-
const wAt = (d: number) => band + head * Math.exp(-(d * d) / 9)
|
|
159
|
-
const a = e * (P / 2 + over)
|
|
160
|
-
const g = P - 2 * a
|
|
161
|
-
if (g > wAt(0)) {
|
|
162
|
-
const k = Math.max(1, Math.round(a / ds))
|
|
163
|
-
const out: Pt[] = []
|
|
164
|
-
const inn: Pt[] = []
|
|
165
|
-
for (let j = -k; j <= k; j++) {
|
|
166
|
-
const p = at(i0 + j)
|
|
167
|
-
const w = wAt((k - Math.abs(j)) * ds) / 2
|
|
168
|
-
out.push([p[0] + p[2] * w, p[1] + p[3] * w])
|
|
169
|
-
inn.push([p[0] - p[2] * w, p[1] - p[3] * w])
|
|
170
|
-
}
|
|
171
|
-
// A round drop head on each end.
|
|
172
|
-
const cap = (p: Ring[number], dir: number, from: number): Pt[] => {
|
|
173
|
-
const r = wAt(0) / 2
|
|
174
|
-
const n = [p[2] * from, p[3] * from]
|
|
175
|
-
const t = [-p[3] * dir, p[2] * dir]
|
|
176
|
-
const c: Pt[] = []
|
|
177
|
-
for (let q = 1; q < 10; q++) {
|
|
178
|
-
const th = (q / 10) * Math.PI
|
|
179
|
-
c.push([p[0] + r * (n[0] * Math.cos(th) + t[0] * Math.sin(th)), p[1] + r * (n[1] * Math.cos(th) + t[1] * Math.sin(th))])
|
|
180
|
-
}
|
|
181
|
-
return c
|
|
182
|
-
}
|
|
183
|
-
return [out.concat(cap(at(i0 + k), 1, 1), inn.reverse(), cap(at(i0 - k), -1, -1))]
|
|
184
|
-
}
|
|
185
|
-
const iM = (i0 + Math.round(N / 2)) % N
|
|
186
|
-
const m = clamp01((g + 2 * over) / (wAt(0) + 2 * over))
|
|
187
|
-
const out: Pt[] = []
|
|
188
|
-
const inn: Pt[] = []
|
|
189
|
-
for (let i = 0; i < N; i++) {
|
|
190
|
-
let dj = Math.abs(i - iM) % N
|
|
191
|
-
dj = Math.min(dj, N - dj) * ds
|
|
192
|
-
const p = cl[i]
|
|
193
|
-
const w = (band + head * m * Math.exp(-(dj * dj) / 16)) / 2
|
|
194
|
-
out.push([p[0] + p[2] * w, p[1] + p[3] * w])
|
|
195
|
-
inn.push([p[0] - p[2] * w, p[1] - p[3] * w])
|
|
196
|
-
}
|
|
197
|
-
return [out, inn]
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function nearestOn(cl: Ring, x: number, y: number) {
|
|
201
|
-
let best = 0
|
|
202
|
-
let m = Infinity
|
|
203
|
-
cl.forEach((p, i) => {
|
|
204
|
-
const d = (p[0] - x) ** 2 + (p[1] - y) ** 2
|
|
205
|
-
if (d < m) {
|
|
206
|
-
m = d
|
|
207
|
-
best = i
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
return best
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Field focus: while `target` matches `on`, it carries data-edge, which its CSS draws as the dark edge
|
|
215
|
-
* (the field's focus indicator, --gooee-line-focus thick).
|
|
216
|
-
* When it starts to match, the edge first flows both ways round from where it was pressed (or from the
|
|
217
|
-
* start edge for a key) and meets on the far side, then data-edge lands; when it stops mid-flow, the
|
|
218
|
-
* drawing fades. The layer sits in `host` (the target itself, or a wrapper for a textarea).
|
|
219
|
-
*/
|
|
6
|
+
/** React's hold on edgeFlow (motion/liquidMore.ts): the field's focus edge flows round from where it was pressed. */
|
|
220
7
|
export function useEdgeFlow(target: RefObject<HTMLElement | null>, host: RefObject<HTMLElement | null>, on: string, cls: string) {
|
|
221
8
|
useEffect(() => {
|
|
222
9
|
const el = target.current
|
|
223
10
|
const root = host.current
|
|
224
11
|
if (!el || !root) return
|
|
225
|
-
|
|
226
|
-
if (shown) el.dataset.edge = ''
|
|
227
|
-
let pressed: { x: number; y: number; t: number } | null = null
|
|
228
|
-
let run: { svg: SVGSVGElement; stop: () => void } | null = null
|
|
229
|
-
const end = () => {
|
|
230
|
-
run?.stop()
|
|
231
|
-
run?.svg.remove()
|
|
232
|
-
run = null
|
|
233
|
-
}
|
|
234
|
-
const settle = () => {
|
|
235
|
-
end()
|
|
236
|
-
if (shown) el.dataset.edge = ''
|
|
237
|
-
}
|
|
238
|
-
const start = () => {
|
|
239
|
-
end()
|
|
240
|
-
const ms = motionFor('base') + motionFor('instant')
|
|
241
|
-
if (!ms) return settle()
|
|
242
|
-
const look = getComputedStyle(el)
|
|
243
|
-
// The settled edge is a focus indicator: --gooee-line-focus thick, inside the border box.
|
|
244
|
-
const bw = parseFloat(look.getPropertyValue('--gooee-line-focus')) || 2
|
|
245
|
-
const r = parseFloat(look.borderTopLeftRadius) || 0
|
|
246
|
-
const rect = el.getBoundingClientRect()
|
|
247
|
-
let W = el.offsetWidth
|
|
248
|
-
let H = el.offsetHeight
|
|
249
|
-
const ringOf = () => boxRing({ cx: W / 2, cy: H / 2, hw: (W - bw) / 2, hh: (H - bw) / 2, r: Math.max(0, r - bw / 2) }, 0.5)
|
|
250
|
-
let cl = ringOf()
|
|
251
|
-
const fresh = pressed && performance.now() - pressed.t < 1000
|
|
252
|
-
const rtl = look.direction === 'rtl'
|
|
253
|
-
const i0 = fresh ? nearestOn(cl, pressed!.x - rect.left, pressed!.y - rect.top) : nearestOn(cl, rtl ? W : 0, H / 2)
|
|
254
|
-
let at = i0 / cl.length
|
|
255
|
-
pressed = null
|
|
256
|
-
const { svg, paths } = layer(root, cls, null)
|
|
257
|
-
const path = paths[0]
|
|
258
|
-
path.style.fill = look.getPropertyValue('--gooee-flow-edge').trim() || 'currentColor'
|
|
259
|
-
path.setAttribute('fill-rule', 'evenodd')
|
|
260
|
-
path.setAttribute('data-measure', 'shape')
|
|
261
|
-
const place = () => {
|
|
262
|
-
svg.setAttribute('width', `${W}`)
|
|
263
|
-
svg.setAttribute('height', `${H}`)
|
|
264
|
-
svg.style.left = `${el === root ? -el.clientLeft : el.offsetLeft}px`
|
|
265
|
-
svg.style.top = `${el === root ? -el.clientTop : el.offsetTop}px`
|
|
266
|
-
}
|
|
267
|
-
place()
|
|
268
|
-
const e = morphEase()
|
|
269
|
-
const draw = (u: number) => {
|
|
270
|
-
// A field that grows while it flows (a textarea) keeps the flow on its edge.
|
|
271
|
-
if (el.offsetWidth !== W || el.offsetHeight !== H) {
|
|
272
|
-
W = el.offsetWidth
|
|
273
|
-
H = el.offsetHeight
|
|
274
|
-
cl = ringOf()
|
|
275
|
-
place()
|
|
276
|
-
}
|
|
277
|
-
if (u >= 1) {
|
|
278
|
-
path.setAttribute('d', boxPath({ cx: W / 2, cy: H / 2, hw: W / 2, hh: H / 2, r }) + boxPath({ cx: W / 2, cy: H / 2, hw: W / 2 - bw, hh: H / 2 - bw, r: Math.max(0, r - bw) }))
|
|
279
|
-
return
|
|
280
|
-
}
|
|
281
|
-
path.setAttribute('d', edgeLoops(cl, Math.round(at * cl.length), e(u), bw).map((l) => polyPath(l)).join(''))
|
|
282
|
-
}
|
|
283
|
-
run = { svg, stop: frames(ms, draw, settle) }
|
|
284
|
-
}
|
|
285
|
-
const leave = () => {
|
|
286
|
-
if (!run) return
|
|
287
|
-
const r = run
|
|
288
|
-
r.stop()
|
|
289
|
-
const ms = motionFor('fast')
|
|
290
|
-
if (!ms || typeof r.svg.animate !== 'function') return end()
|
|
291
|
-
const fade = r.svg.animate({ opacity: [1, 0] }, { duration: ms, easing: 'linear', fill: 'forwards' })
|
|
292
|
-
r.stop = () => fade.cancel()
|
|
293
|
-
fade.finished.then(() => run === r && end(), () => {})
|
|
294
|
-
}
|
|
295
|
-
const check = () => {
|
|
296
|
-
const now = el.matches(on)
|
|
297
|
-
if (now === shown) return
|
|
298
|
-
shown = now
|
|
299
|
-
if (now) start()
|
|
300
|
-
else {
|
|
301
|
-
delete el.dataset.edge
|
|
302
|
-
leave()
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
const later = () => queueMicrotask(check)
|
|
306
|
-
const down = (ev: PointerEvent) => {
|
|
307
|
-
pressed = { x: ev.clientX, y: ev.clientY, t: performance.now() }
|
|
308
|
-
}
|
|
309
|
-
const watch = new MutationObserver(check)
|
|
310
|
-
watch.observe(el, { attributes: true, attributeFilter: ['data-open', 'data-invalid'] })
|
|
311
|
-
el.addEventListener('pointerdown', down, true)
|
|
312
|
-
el.addEventListener('focusin', later)
|
|
313
|
-
el.addEventListener('focusout', later)
|
|
314
|
-
return () => {
|
|
315
|
-
watch.disconnect()
|
|
316
|
-
el.removeEventListener('pointerdown', down, true)
|
|
317
|
-
el.removeEventListener('focusin', later)
|
|
318
|
-
el.removeEventListener('focusout', later)
|
|
319
|
-
end()
|
|
320
|
-
delete el.dataset.edge
|
|
321
|
-
}
|
|
12
|
+
return edgeFlow(el, root, on, cls)
|
|
322
13
|
}, [target, host, on, cls])
|
|
323
14
|
}
|
|
324
15
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const sdSeg = (x: number, y: number, a: Pt, b: Pt) => {
|
|
328
|
-
const bx = b[0] - a[0]
|
|
329
|
-
const by = b[1] - a[1]
|
|
330
|
-
const L = bx * bx + by * by
|
|
331
|
-
const h = L > 0 ? clamp01(((x - a[0]) * bx + (y - a[1]) * by) / L) : 0
|
|
332
|
-
return Math.hypot(x - a[0] - bx * h, y - a[1] - by * h)
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
* Distance to a stroke of half width `w`: two arms from B (directions u1 and u2, lengths L1 and L2)
|
|
337
|
-
* joined by an arc of radius rc. Its outline is an exact offset of a smooth centre line, so it is as
|
|
338
|
-
* wide everywhere and has no point.
|
|
339
|
-
*/
|
|
340
|
-
function strokeSdf(B: Pt, u1: Pt, u2: Pt, L1: number, L2: number, rc: number, w: number): Sdf {
|
|
341
|
-
const e1: Pt = [B[0] + u1[0] * L1, B[1] + u1[1] * L1]
|
|
342
|
-
const e2: Pt = [B[0] + u2[0] * L2, B[1] + u2[1] * L2]
|
|
343
|
-
const phi = Math.acos(Math.max(-1, Math.min(1, u1[0] * u2[0] + u1[1] * u2[1])))
|
|
344
|
-
const beta = Math.PI - phi
|
|
345
|
-
if (beta < 1e-4) return (x, y) => Math.min(sdSeg(x, y, B, e1), sdSeg(x, y, B, e2)) - w
|
|
346
|
-
const T = rc * Math.tan(beta / 2)
|
|
347
|
-
const p1: Pt = [B[0] + u1[0] * T, B[1] + u1[1] * T]
|
|
348
|
-
const p2: Pt = [B[0] + u2[0] * T, B[1] + u2[1] * T]
|
|
349
|
-
const bl = Math.hypot(u1[0] + u2[0], u1[1] + u2[1])
|
|
350
|
-
const oc = rc / Math.sin(phi / 2)
|
|
351
|
-
const O: Pt = [B[0] + ((u1[0] + u2[0]) / bl) * oc, B[1] + ((u1[1] + u2[1]) / bl) * oc]
|
|
352
|
-
const a: Pt = [p1[0] - O[0], p1[1] - O[1]]
|
|
353
|
-
const b: Pt = [p2[0] - O[0], p2[1] - O[1]]
|
|
354
|
-
const cr = (m: Pt, n: Pt) => m[0] * n[1] - m[1] * n[0]
|
|
355
|
-
const sg = Math.sign(cr(a, b))
|
|
356
|
-
return (x, y) => {
|
|
357
|
-
let d = Math.min(sdSeg(x, y, p1, e1), sdSeg(x, y, p2, e2))
|
|
358
|
-
const v: Pt = [x - O[0], y - O[1]]
|
|
359
|
-
if (cr(a, v) * sg >= 0 && cr(v, b) * sg >= 0) d = Math.min(d, Math.abs(Math.hypot(v[0], v[1]) - rc))
|
|
360
|
-
return d - w
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/** The filled square (`sq`) and the check it becomes: its corner B, arm lengths and half width. */
|
|
365
|
-
export type CheckMorph = { sq: Box; B: Pt; L1: number; L2: number; w: number }
|
|
366
|
-
|
|
367
|
-
const ROUND = 0.04
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* The filled square at m = 0 becomes the check at m = 1 in one shape: it rounds into a drop (the first
|
|
371
|
-
* 4%), stretches into a bar, and bends into the check as it thins. Through the bend the join radius
|
|
372
|
-
* stays at least 1.9 times the half width, so its inside never pinches.
|
|
373
|
-
*/
|
|
374
|
-
export function checkLoops(m: number, g: CheckMorph): Pt[][] {
|
|
375
|
-
const { sq } = g
|
|
376
|
-
if (m < ROUND) {
|
|
377
|
-
const q = m / ROUND
|
|
378
|
-
const r = lerp(sq.r, sq.hw, q * q * (3 - 2 * q))
|
|
379
|
-
return [boxRing({ ...sq, r }, 0.5).map((p) => [p[0], p[1]] as Pt)]
|
|
380
|
-
}
|
|
381
|
-
const t = (m - ROUND) / (1 - ROUND)
|
|
382
|
-
const w = lerp(sq.hw, g.w, t)
|
|
383
|
-
const rc = 1.9 * w + 0.2
|
|
384
|
-
const B: Pt = [lerp(sq.cx, g.B[0], t), lerp(sq.cy, g.B[1], t)]
|
|
385
|
-
const L1 = g.L1 * t
|
|
386
|
-
const L2 = g.L2 * t
|
|
387
|
-
const sm = t * t * (3 - 2 * t)
|
|
388
|
-
const beta = Math.min((Math.PI / 2) * sm, 2 * Math.atan((0.95 * Math.min(L1, L2)) / rc))
|
|
389
|
-
const phi = Math.PI - beta
|
|
390
|
-
const up = -Math.PI / 2
|
|
391
|
-
const u1: Pt = [Math.cos(up - phi / 2), Math.sin(up - phi / 2)]
|
|
392
|
-
const u2: Pt = [Math.cos(up + phi / 2), Math.sin(up + phi / 2)]
|
|
393
|
-
const T = rc * Math.tan(beta / 2)
|
|
394
|
-
return trace(strokeSdf(B, u1, u2, L1, L2, rc, w), [[B[0] + u1[0] * T, B[1] + u1[1] * T, 0, 1]])
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/** Where a copy run is: front filled, back slid under, square morphed into the check, each 0 to 1. */
|
|
398
|
-
export type CopyState = { fill: number; slide: number; morph: number }
|
|
399
|
-
|
|
400
|
-
// The copy icon (internal/icons CopyIcon) in its 24-unit box, and the check's corner and arms.
|
|
401
|
-
const ICON = { front: 8.5, size: 11, r: 2.5, back: 4, stroke: 1.75, B: [9.5, 17] as Pt, L1: 4.5 * Math.SQRT2, L2: 9.5 * Math.SQRT2, check: 2.25 }
|
|
402
|
-
const BACK_D = 'M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2'
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* CopyButton: a drop forms where it was pressed (`at`, from the icon's corner; null for a key), falls
|
|
406
|
-
* into the copy icon and fills its front square, the back square slides under and merges, and the
|
|
407
|
-
* filled square turns into the check. `to` 0 plays it back from wherever it is. The icon box carries
|
|
408
|
-
* data-pouring while it runs, so the CSS icons stand down.
|
|
409
|
-
*/
|
|
410
|
-
export function copyRun(icons: HTMLElement, to: 0 | 1, at: Pt | null, cls: string, prev: CopyRun | null): CopyRun | null {
|
|
411
|
-
if (prev?.done) prev = null
|
|
412
|
-
const from: CopyState = prev ? { ...prev.state } : to ? { fill: 0, slide: 0, morph: 0 } : { fill: 1, slide: 1, morph: 1 }
|
|
413
|
-
prev?.halt()
|
|
414
|
-
const k = motionFor('morph') / 600
|
|
415
|
-
if (!k) {
|
|
416
|
-
prev?.stop()
|
|
417
|
-
return null
|
|
418
|
-
}
|
|
419
|
-
const size = icons.offsetWidth
|
|
420
|
-
const s = size / 24
|
|
421
|
-
const o = (ICON.front - ICON.stroke / 2) * s
|
|
422
|
-
const S = (ICON.size + ICON.stroke) * s
|
|
423
|
-
const sq: Box = { cx: o + S / 2, cy: o + S / 2, hw: S / 2, hh: S / 2, r: (ICON.r + ICON.stroke / 2) * s }
|
|
424
|
-
const ring = ICON.stroke * s
|
|
425
|
-
const hole: Box = { ...sq, hw: S / 2 - ring, hh: S / 2 - ring, r: Math.max(0, sq.r - ring) }
|
|
426
|
-
const frontD = boxPath(sq)
|
|
427
|
-
const g: CheckMorph = { sq, B: [ICON.B[0] * s, ICON.B[1] * s], L1: ICON.L1 * s, L2: ICON.L2 * s, w: (ICON.check / 2) * s }
|
|
428
|
-
const inner = hole.hw * 2
|
|
429
|
-
const cup: Cup = { x0: hole.cx - hole.hw, x1: hole.cx + hole.hw, top: hole.cy - hole.hh, bot: hole.cy + hole.hh, tilt: inner * 0.29, men: inner * 0.1 }
|
|
430
|
-
const entry: Pt = [sq.cx, cup.top + 1]
|
|
431
|
-
const drop = !prev && to === 1
|
|
432
|
-
const P: Pt = at ?? [size / 2, size / 2]
|
|
433
|
-
const side = Math.max(-1, Math.min(1, (P[0] - entry[0]) / 32)) * 0.6
|
|
434
|
-
let svg = prev?.svg
|
|
435
|
-
let p: { back: SVGPathElement; liquid: SVGPathElement; front: SVGPathElement; drop: SVGPathElement; clip: string }
|
|
436
|
-
if (svg && prev) p = prev.paths
|
|
437
|
-
else {
|
|
438
|
-
const l = layer(icons, cls, null, 4)
|
|
439
|
-
svg = l.svg
|
|
440
|
-
svg.setAttribute('width', `${size}`)
|
|
441
|
-
svg.setAttribute('height', `${size}`)
|
|
442
|
-
const [back, liquid, front, dropPath] = l.paths
|
|
443
|
-
const inside = clipOf(svg)
|
|
444
|
-
inside.path.setAttribute('d', frontD)
|
|
445
|
-
// The back square shows only outside the front one, so it slides under it.
|
|
446
|
-
const outside = clipOf(svg)
|
|
447
|
-
outside.path.setAttribute('d', `M-${size} -${size}H${2 * size}V${2 * size}H-${size}Z${frontD}`)
|
|
448
|
-
outside.path.setAttribute('clip-rule', 'evenodd')
|
|
449
|
-
back.setAttribute('d', BACK_D)
|
|
450
|
-
back.setAttribute('clip-path', outside.url)
|
|
451
|
-
back.style.cssText = `fill:none;stroke:currentColor;stroke-width:${ICON.stroke};stroke-linecap:round;stroke-linejoin:round`
|
|
452
|
-
front.setAttribute('fill-rule', 'evenodd')
|
|
453
|
-
for (const q of [liquid, front, dropPath]) q.style.fill = 'currentColor'
|
|
454
|
-
dropPath.setAttribute('data-measure', 'shape')
|
|
455
|
-
p = { back, liquid, front, drop: dropPath, clip: inside.url }
|
|
456
|
-
}
|
|
457
|
-
icons.dataset.pouring = ''
|
|
458
|
-
const e = morphEase()
|
|
459
|
-
const s2 = (rel: number, a: number, b: number) => clamp01((rel - a * k) / ((b - a) * k))
|
|
460
|
-
const toward = (v: number, t: number) => lerp(v, to, e(t))
|
|
461
|
-
const ms = (to ? (drop ? 600 : 440) : 560) * k
|
|
462
|
-
const layerSvg = svg
|
|
463
|
-
const run: CopyRun = {
|
|
464
|
-
state: { ...from },
|
|
465
|
-
done: false,
|
|
466
|
-
svg: layerSvg,
|
|
467
|
-
paths: p,
|
|
468
|
-
halt: () => {},
|
|
469
|
-
stop: () => {
|
|
470
|
-
run.done = true
|
|
471
|
-
run.halt()
|
|
472
|
-
layerSvg.remove()
|
|
473
|
-
delete icons.dataset.pouring
|
|
474
|
-
},
|
|
475
|
-
}
|
|
476
|
-
const frame = (rel: number) => {
|
|
477
|
-
const st = run.state
|
|
478
|
-
let dp: { x: number; y: number; r: number } | null = null
|
|
479
|
-
if (to) {
|
|
480
|
-
// From rest: the drop forms, flies and sinks in, then the front fills, the back slides under and
|
|
481
|
-
// the square becomes the check. From part way: the same order, without the drop.
|
|
482
|
-
const [f0, f1, s0, s1, m0, m1] = drop ? [160, 300, 200, 300, 300, 600] : [0, 140, 40, 140, 140, 440]
|
|
483
|
-
st.fill = toward(from.fill, s2(rel, f0, f1))
|
|
484
|
-
st.slide = toward(from.slide, s2(rel, s0, s1))
|
|
485
|
-
st.morph = toward(from.morph, s2(rel, m0, m1))
|
|
486
|
-
if (drop) {
|
|
487
|
-
const form = s2(rel, 0, 70)
|
|
488
|
-
const fly = s2(rel, 70, 190)
|
|
489
|
-
const sink = s2(rel, 190, 240)
|
|
490
|
-
const q = fly * fly * (3 - 2 * fly)
|
|
491
|
-
const r = size * 0.15 * e(form) * (1 - sink)
|
|
492
|
-
if (r > 0.05) dp = { x: lerp(P[0], entry[0], q), y: lerp(P[1], entry[1], q) - size * 2 * q * (1 - q) + size * 0.25 * sink, r }
|
|
493
|
-
}
|
|
494
|
-
} else {
|
|
495
|
-
st.morph = toward(from.morph, s2(rel, 0, 300))
|
|
496
|
-
st.slide = toward(from.slide, s2(rel, 300, 400))
|
|
497
|
-
st.fill = toward(from.fill, s2(rel, 380, 560))
|
|
498
|
-
}
|
|
499
|
-
const full = st.fill >= 1
|
|
500
|
-
const { liquid } = p
|
|
501
|
-
if (st.fill <= 0) {
|
|
502
|
-
liquid.removeAttribute('clip-path')
|
|
503
|
-
liquid.removeAttribute('data-measure')
|
|
504
|
-
liquid.setAttribute('d', '')
|
|
505
|
-
} else if (!full) {
|
|
506
|
-
liquid.setAttribute('clip-path', p.clip)
|
|
507
|
-
liquid.setAttribute('data-measure', 'surface')
|
|
508
|
-
liquid.setAttribute('data-cup', cupAttr(cup))
|
|
509
|
-
liquid.setAttribute('d', cupPath(cupLevel(st.fill, side, cup), sq.cx - sq.hw - 1, sq.cx + sq.hw + 1, sq.cy + sq.hh + 2))
|
|
510
|
-
} else {
|
|
511
|
-
liquid.removeAttribute('clip-path')
|
|
512
|
-
// The square itself is the icon's own shape; the morph is judged from the first step on.
|
|
513
|
-
if (st.morph > 0) liquid.setAttribute('data-measure', 'morph')
|
|
514
|
-
else liquid.removeAttribute('data-measure')
|
|
515
|
-
liquid.setAttribute('d', st.morph > 0 ? checkLoops(st.morph, g).map((l) => polyPath(l)).join('') : frontD)
|
|
516
|
-
}
|
|
517
|
-
// Once the front is full, its outline and the hidden back square are under the ink.
|
|
518
|
-
p.front.setAttribute('d', full ? '' : frontD + boxPath(hole))
|
|
519
|
-
p.back.setAttribute('d', full && st.slide >= 1 ? '' : BACK_D)
|
|
520
|
-
const off = ICON.back * s * st.slide
|
|
521
|
-
p.back.setAttribute('transform', `translate(${off} ${off}) scale(${s})`)
|
|
522
|
-
p.drop.setAttribute('d', dp ? `M${dp.x - dp.r} ${dp.y}a${dp.r} ${dp.r} 0 1 0 ${2 * dp.r} 0a${dp.r} ${dp.r} 0 1 0 ${-2 * dp.r} 0Z` : '')
|
|
523
|
-
}
|
|
524
|
-
run.halt = frames(ms, (u) => frame(u * ms), () => run.stop())
|
|
525
|
-
return run
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
export type CopyRun = {
|
|
529
|
-
state: CopyState
|
|
530
|
-
done: boolean
|
|
531
|
-
svg: SVGSVGElement
|
|
532
|
-
paths: { back: SVGPathElement; liquid: SVGPathElement; front: SVGPathElement; drop: SVGPathElement; clip: string }
|
|
533
|
-
halt: () => void
|
|
534
|
-
stop: () => void
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// ---------- menu bead ----------
|
|
538
|
-
|
|
539
|
-
function smin(a: number, b: number, k: number) {
|
|
540
|
-
if (k <= 1e-6) return Math.min(a, b)
|
|
541
|
-
const h = Math.max(k - Math.abs(a - b), 0) / k
|
|
542
|
-
return Math.min(a, b) - (h * h * h * k) / 6
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
// Up to SLIDE px apart, front and tail are one stretched box. Past it the tail narrows and a neck
|
|
546
|
-
// forms, never longer than NECK px.
|
|
547
|
-
const SLIDE = 24
|
|
548
|
-
const NECK = 24
|
|
549
|
-
|
|
550
|
-
/** The bead with its front at F and its tail at T (centres on y), each with its half height. */
|
|
551
|
-
export function beadLoops(cx: number, hw: number, r: number, F: { y: number; hh: number }, T: { y: number; hh: number }): Pt[][] {
|
|
552
|
-
const d = Math.abs(F.y - T.y)
|
|
553
|
-
if (d <= SLIDE) {
|
|
554
|
-
const y0 = Math.min(F.y - F.hh, T.y - T.hh)
|
|
555
|
-
const y1 = Math.max(F.y + F.hh, T.y + T.hh)
|
|
556
|
-
return [boxRing({ cx, cy: (y0 + y1) / 2, hw, hh: (y1 - y0) / 2, r }, 0.5).map((p) => [p[0], p[1]] as Pt)]
|
|
557
|
-
}
|
|
558
|
-
const e = clamp01((d - SLIDE) / 30)
|
|
559
|
-
const kk = 18 * e
|
|
560
|
-
const hwT = hw * (1 - 0.1 * e * e)
|
|
561
|
-
const hhT = T.hh - 6 * e
|
|
562
|
-
const my = (F.y + T.y) / 2
|
|
563
|
-
// Wide until the gap between the two is tall enough for round fillets, so no slot opens between them.
|
|
564
|
-
const gq = clamp01((d - F.hh - hhT - 12) / 14)
|
|
565
|
-
const nw = lerp(hwT - 2, Math.min(30, hwT - 2), gq * gq * (3 - 2 * gq))
|
|
566
|
-
const sdf: Sdf = (x, y) =>
|
|
567
|
-
smin(smin(sdBox(x, y, { cx, cy: F.y, hw, hh: F.hh, r }), sdBox(x, y, { cx, cy: T.y, hw: hwT, hh: hhT, r }), kk), sdBox(x, y, { cx, cy: my, hw: nw, hh: d / 2, r: Math.min(nw, 8) }), kk)
|
|
568
|
-
return trace(sdf, [[cx, F.y, 1, 0]])
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Menu items: the hover fill is a bead that follows focus (which follows the pointer) from item to
|
|
573
|
-
* item. A next item settles in about 100ms with a slight stretch; a jump of two or more stretches a
|
|
574
|
-
* short neck. While it moves `panel` carries data-bead, so the items' own fill stands down; at rest
|
|
575
|
-
* the focused item's CSS fill is back. Focus leaving the panel mid-move fades the bead where it is.
|
|
576
|
-
* Only this panel's own items count (submenus sit inside it).
|
|
577
|
-
*/
|
|
16
|
+
/** React's hold on bead (motion/liquidMore.ts): the menu's hover fill follows focus from item to item. */
|
|
578
17
|
export function useBead(panel: RefObject<HTMLElement | null>, on: boolean, cls: string) {
|
|
579
18
|
useEffect(() => {
|
|
580
19
|
const root = panel.current
|
|
581
20
|
if (!root || !on) return
|
|
582
|
-
|
|
583
|
-
let goal: HTMLElement | null = null
|
|
584
|
-
let run: { svg: SVGSVGElement; path: SVGPathElement; id: number; last: number } | null = null
|
|
585
|
-
const itemOf = (t: EventTarget | null) => {
|
|
586
|
-
const el = t instanceof Element ? t.closest<HTMLElement>('[role^="menuitem"]') : null
|
|
587
|
-
return el && el.closest('[role="menu"]') === root ? el : null
|
|
588
|
-
}
|
|
589
|
-
// Layout boxes, not screen ones: the panel and its items may be mid scale or slide as they arrive.
|
|
590
|
-
const boxOf = (el: HTMLElement) => {
|
|
591
|
-
let x = 0
|
|
592
|
-
let y = 0
|
|
593
|
-
for (let n: HTMLElement | null = el; n && n !== root; n = n.offsetParent as HTMLElement | null) {
|
|
594
|
-
x += n.offsetLeft
|
|
595
|
-
y += n.offsetTop
|
|
596
|
-
if (n.offsetParent && n.offsetParent !== root) {
|
|
597
|
-
x += (n.offsetParent as HTMLElement).clientLeft
|
|
598
|
-
y += (n.offsetParent as HTMLElement).clientTop
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
return { x, y, w: el.offsetWidth, h: el.offsetHeight }
|
|
602
|
-
}
|
|
603
|
-
const end = () => {
|
|
604
|
-
if (!run) return
|
|
605
|
-
cancelAnimationFrame(run.id)
|
|
606
|
-
run.svg.remove()
|
|
607
|
-
run = null
|
|
608
|
-
// The focused item's own fill comes back at once, not through its fade.
|
|
609
|
-
const el = goal
|
|
610
|
-
if (el) el.style.transition = 'none'
|
|
611
|
-
delete root.dataset.bead
|
|
612
|
-
if (el) {
|
|
613
|
-
void getComputedStyle(el).backgroundColor
|
|
614
|
-
el.style.removeProperty('transition')
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
const tick = (now: number) => {
|
|
618
|
-
if (!run || !goal) return
|
|
619
|
-
const dt = Math.min(64, Math.max(0, now - run.last))
|
|
620
|
-
run.last = now
|
|
621
|
-
const fast = motionFor('fast')
|
|
622
|
-
const b = boxOf(goal)
|
|
623
|
-
const gy = b.y + b.h / 2
|
|
624
|
-
const gh = b.h / 2
|
|
625
|
-
st.F += (gy - st.F) * (1 - Math.exp(-dt / (fast / 9)))
|
|
626
|
-
st.hF += (gh - st.hF) * (1 - Math.exp(-dt / (fast / 9)))
|
|
627
|
-
st.T += (st.F - st.T) * (1 - Math.exp(-dt / (fast / 7)))
|
|
628
|
-
st.hT += (st.hF - st.hT) * (1 - Math.exp(-dt / (fast / 7)))
|
|
629
|
-
const most = st.hF + st.hT - 6 + NECK
|
|
630
|
-
if (Math.abs(st.F - st.T) > most) st.T = st.F - Math.sign(st.F - st.T) * most
|
|
631
|
-
const r = parseFloat(getComputedStyle(goal).borderTopLeftRadius) || 0
|
|
632
|
-
if (Math.abs(gy - st.F) < 0.05 && Math.abs(st.F - st.T) < 0.05 && Math.abs(gh - st.hT) < 0.05) {
|
|
633
|
-
run.path.setAttribute('d', boxPath({ cx: b.x + b.w / 2, cy: gy, hw: b.w / 2, hh: gh, r }))
|
|
634
|
-
end()
|
|
635
|
-
return
|
|
636
|
-
}
|
|
637
|
-
const loops = beadLoops(b.x + b.w / 2, b.w / 2, r, { y: st.F, hh: st.hF }, { y: st.T, hh: st.hT })
|
|
638
|
-
run.path.setAttribute('d', loops.map((l) => polyPath(l, 2)).join(''))
|
|
639
|
-
run.id = requestAnimationFrame(tick)
|
|
640
|
-
}
|
|
641
|
-
const focusIn = (ev: FocusEvent) => {
|
|
642
|
-
const to = itemOf(ev.target)
|
|
643
|
-
if (!to) return
|
|
644
|
-
const from = itemOf(ev.relatedTarget)
|
|
645
|
-
goal = to
|
|
646
|
-
if (!motionFor('fast')) return end()
|
|
647
|
-
if (!run) {
|
|
648
|
-
// A first highlight just appears (its CSS fade); only a move between items flows.
|
|
649
|
-
if (!from || from === to) return
|
|
650
|
-
root.dataset.bead = ''
|
|
651
|
-
const b = boxOf(from)
|
|
652
|
-
st.F = st.T = b.y + b.h / 2
|
|
653
|
-
st.hF = st.hT = b.h / 2
|
|
654
|
-
const { svg, paths } = layer(root, cls, root.firstChild)
|
|
655
|
-
svg.setAttribute('width', `${root.scrollWidth}`)
|
|
656
|
-
svg.setAttribute('height', `${root.scrollHeight}`)
|
|
657
|
-
paths[0].setAttribute('data-measure', 'shape')
|
|
658
|
-
run = { svg, path: paths[0], id: 0, last: performance.now() }
|
|
659
|
-
run.id = requestAnimationFrame(tick)
|
|
660
|
-
tick(performance.now())
|
|
661
|
-
}
|
|
662
|
-
if (run) run.path.style.fill = getComputedStyle(to).getPropertyValue('--gooee-bead').trim()
|
|
663
|
-
}
|
|
664
|
-
const focusOut = (ev: FocusEvent) => {
|
|
665
|
-
if (!run || itemOf(ev.relatedTarget)) return
|
|
666
|
-
const r = run
|
|
667
|
-
cancelAnimationFrame(r.id)
|
|
668
|
-
run = null
|
|
669
|
-
goal = null
|
|
670
|
-
delete root.dataset.bead
|
|
671
|
-
const ms = motionFor('fast')
|
|
672
|
-
if (!ms || typeof r.svg.animate !== 'function') return r.svg.remove()
|
|
673
|
-
r.svg.animate({ opacity: [1, 0] }, { duration: ms, easing: 'linear', fill: 'forwards' }).finished.then(
|
|
674
|
-
() => r.svg.remove(),
|
|
675
|
-
() => r.svg.remove(),
|
|
676
|
-
)
|
|
677
|
-
}
|
|
678
|
-
root.addEventListener('focusin', focusIn)
|
|
679
|
-
root.addEventListener('focusout', focusOut)
|
|
680
|
-
return () => {
|
|
681
|
-
root.removeEventListener('focusin', focusIn)
|
|
682
|
-
root.removeEventListener('focusout', focusOut)
|
|
683
|
-
end()
|
|
684
|
-
}
|
|
21
|
+
return bead(root, cls)
|
|
685
22
|
}, [panel, on, cls])
|
|
686
23
|
}
|