(change-detail from to reason)Build the detail map for an x-morph-stack-change event.
Build the detail map for an x-morph-stack-change event.
(changed-detail from to)Build the detail map for an x-morph-stack-changed event.
Build the detail map for an x-morph-stack-changed event.
(diff-morph-ids old-ids new-ids)Given two collections of morph-ids, partition into matched/entering/leaving.
Given two collections of morph-ids, partition into matched/entering/leaving.
(goo-matrix-values threshold)Build the feColorMatrix values string for a given alpha multiplier.
The alpha offset is derived linearly from the multiplier so that:
Build the feColorMatrix `values` string for a given alpha multiplier. The alpha offset is derived linearly from the multiplier so that: - threshold = 18 → '0 0 0 18 -7' (the canonical gooey configuration) - threshold = 1 → '0 0 0 1 0' (the identity alpha row, no goo effect) This lets callers tween a single number toward 1 to fade the gooey filter smoothly into a no-op as the morph spring settles, avoiding a visual snap when the filtered ghost is replaced by the un-filtered real element.
(lerp a b t)Linear interpolation between a and b at progress t (0..1).
Linear interpolation between a and b at progress t (0..1).
(lerp-color a b t)Lerp two CSS rgb/rgba colors. If either fails to parse, snaps at midpoint.
Lerp two CSS rgb/rgba colors. If either fails to parse, snaps at midpoint.
(lerp-radius-list a b t)Lerp two border-radius strings. Both must be matched-shape px lists. Falls back to snap-at-midpoint when shapes differ.
Lerp two border-radius strings. Both must be matched-shape px lists. Falls back to snap-at-midpoint when shapes differ.
(natural-duration-ms stiffness damping mass)Estimate the spring's natural settle time in milliseconds from the current
stiffness, damping, and mass. Combines two physical effects:
ω₀ = √(k/m) (undamped natural angular frequency, rad/s) ζ = c / (2·√(k·m)) (damping ratio)
ts ≈ 4 / (ζ·ω₀) + π / ω₀ = envelope decay + rise time to first reach the target
The envelope-decay term alone simplifies to 8m/c and is therefore insensitive to stiffness — that's mathematically right for the asymptotic decay of the displacement envelope, but it doesn't match the perceived duration because it ignores how fast the spring first arrives. Adding the rise-time term π/ω₀ (which is π·√(m/k)) brings stiffness back in, so a stiffer spring of the same damping is correctly estimated as faster.
Inputs are clamped to safe positive ranges; ζ is clamped to [0.2, 5] so
very low / very high damping doesn't blow the result up. The component
divides this by an author-supplied duration to derive a per-tick time
scale, so the exact constant matters less than its monotonic behaviour
across spring tunings.
Estimate the spring's natural settle time in milliseconds from the current
`stiffness`, `damping`, and `mass`. Combines two physical effects:
ω₀ = √(k/m) (undamped natural angular frequency, rad/s)
ζ = c / (2·√(k·m)) (damping ratio)
ts ≈ 4 / (ζ·ω₀) + π / ω₀
= envelope decay + rise time to first reach the target
The envelope-decay term alone simplifies to 8m/c and is therefore
insensitive to stiffness — that's mathematically right for the asymptotic
decay of the displacement envelope, but it doesn't match the perceived
duration because it ignores how fast the spring first arrives. Adding the
rise-time term π/ω₀ (which is π·√(m/k)) brings stiffness back in, so a
stiffer spring of the same damping is correctly estimated as faster.
Inputs are clamped to safe positive ranges; ζ is clamped to [0.2, 5] so
very low / very high damping doesn't blow the result up. The component
divides this by an author-supplied `duration` to derive a per-tick time
scale, so the exact constant matters less than its monotonic behaviour
across spring tunings.(normalize {:keys [active-state-raw active-index-raw stiffness-raw damping-raw
mass-raw variant-raw duration-raw disabled-present?]})Normalise raw attribute inputs into a stable view-model map.
Input keys: :active-state-raw string | nil :active-index-raw string | nil :stiffness-raw string | nil :damping-raw string | nil :mass-raw string | nil :variant-raw string | nil :duration-raw string | nil :disabled-present? boolean
Output keys: :active-state string | nil :active-index int | nil :stiffness number :damping number :mass number :variant string (one of allowed-variants) :duration number | nil (ms; nil means natural spring time) :disabled? boolean
Normalise raw attribute inputs into a stable view-model map. Input keys: :active-state-raw string | nil :active-index-raw string | nil :stiffness-raw string | nil :damping-raw string | nil :mass-raw string | nil :variant-raw string | nil :duration-raw string | nil :disabled-present? boolean Output keys: :active-state string | nil :active-index int | nil :stiffness number :damping number :mass number :variant string (one of allowed-variants) :duration number | nil (ms; nil means natural spring time) :disabled? boolean
(parse-active-index s)Parse the active-index attribute to a non-negative integer, or nil.
Parse the active-index attribute to a non-negative integer, or nil.
(parse-duration s)Parse the duration attribute (positive number of ms) to a number, or nil. nil / empty / non-numeric / non-positive → nil, meaning the spring runs at its natural settle time.
Parse the duration attribute (positive number of ms) to a number, or nil. nil / empty / non-numeric / non-positive → nil, meaning the spring runs at its natural settle time.
(parse-px-list s)Parse a CSS length list like '8px 12px 4px 0px' into #js [n n n n] (in px). Returns nil if any token is not in px.
Parse a CSS length list like '8px 12px 4px 0px' into #js [n n n n] (in px). Returns nil if any token is not in px.
(parse-rgb-string s)Parse a CSS color in 'rgb(r,g,b)' or 'rgba(r,g,b,a)' form into #js [r g b a]. Returns nil for any other format (transparent, named colors, etc).
Parse a CSS color in 'rgb(r,g,b)' or 'rgba(r,g,b,a)' form into #js [r g b a]. Returns nil for any other format (transparent, named colors, etc).
(parse-variant s)Normalise a raw variant attribute string. Unknown / nil / empty → default.
Normalise a raw variant attribute string. Unknown / nil / empty → default.
(resolve-active state-names {:keys [active-state active-index]})Given a sequence of available state names and the normalised model, return the resolved active state name (string), or nil when no states.
Rules:
Given a sequence of available state names and the normalised model, return the resolved active state name (string), or nil when no states. Rules: 1. If active-state matches a known name → use it. 2. Else clamp active-index (default 0) to [0, count-1] → name at that index. 3. When the list is empty → nil.
(spring-settled? displacement velocity)Returns true when displacement and velocity are below threshold.
Returns true when displacement and velocity are below threshold.
(spring-step current target velocity dt mass tension friction)Single step of damped spring physics (1D) with mass. Returns #js [new-displacement new-velocity]. Acceleration = (tension * (target - current) - friction * velocity) / mass
Single step of damped spring physics (1D) with mass. Returns #js [new-displacement new-velocity]. Acceleration = (tension * (target - current) - friction * velocity) / mass
(time-scale-for duration-ms stiffness damping mass)Compute the per-tick time scale that stretches/compresses the spring's
natural settle time to the requested duration-ms. Returns 1.0 (no scaling)
when duration-ms is nil / non-positive.
Compute the per-tick time scale that stretches/compresses the spring's natural settle time to the requested `duration-ms`. Returns 1.0 (no scaling) when `duration-ms` is nil / non-positive.
(variant-uses-goo? variant)Whether a given variant string installs the SVG gooey filter.
Whether a given variant string installs the SVG gooey filter.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |