fix(app): preserve todo dock across sessions
This commit is contained in:
parent
c45d1db9a0
commit
b27da40a48
16 changed files with 630 additions and 205 deletions
|
|
@ -11,17 +11,30 @@ const eq = (a: Opt | undefined, b: Opt | undefined) =>
|
|||
a?.mass === b?.mass &&
|
||||
a?.velocity === b?.velocity
|
||||
|
||||
export function useSpring(target: () => number, options?: Opt | (() => Opt)) {
|
||||
export function useSpring(target: () => number, options?: Opt | (() => Opt), snapKey?: () => unknown) {
|
||||
const read = () => (typeof options === "function" ? options() : options)
|
||||
const [value, setValue] = createSignal(target())
|
||||
const source = motionValue(value())
|
||||
const spring = motionValue(value())
|
||||
let config = read()
|
||||
let snapValue = snapKey?.()
|
||||
let stop = attachSpring(spring, source, config)
|
||||
let off = spring.on("change", (next: number) => setValue(next))
|
||||
|
||||
createEffect(() => {
|
||||
source.set(target())
|
||||
const next = target()
|
||||
const nextSnap = snapKey?.()
|
||||
if (snapKey && nextSnap !== snapValue) {
|
||||
// State boundaries should adopt their target without animating from the previous context.
|
||||
snapValue = nextSnap
|
||||
stop()
|
||||
spring.jump(next)
|
||||
source.jump(next)
|
||||
stop = attachSpring(spring, source, config)
|
||||
setValue(next)
|
||||
return
|
||||
}
|
||||
source.set(next)
|
||||
})
|
||||
|
||||
createEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue