
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
solenya-animation
Advanced tools
Solenya animation coordinates element animations in response to DOM changes.
Solenya animation coordinates element animations in response to DOM changes.
For context, this package provides 1 of 3 techniques you can use to animate in Solenya:
web-animations-js
shim for the remaining browsers such as Internet Explorer. You can also use third party animation packages.The transitionChildren
function lets you gracefully transition the position and size of each child element as its updated, enters, or leaves the DOM. Use it to build lists where children move around or grow or shrink in response to DOM changes.
It's used as follows:
export class AnimateShuffle extends Component {
@transient items = range(1, 101)
view() {
return div(
button ({ onclick: () => this.shuffle() }, "shuffle"),
div (transitionChildren(), this.items.map(n =>
div ({ key: n }, n)))
)
}
shuffle() {
this.update(() => this.items = shuffle(this.items))
}
}
Each child must have a unique key relative to its siblings. When in doubt, the virtual DOM thinks: Same key? Same element. Different key? Different element. So the key instructs the DOM to honor your exact intent when adding, removing, and updating elements.
The properties of transitionChildren
are:
export type Orientation = "horizontal"|"vertical"
export type Direction = "forwards"|"backwards"
export type AnimationKind = "fade"|"slide"|"scale"
export interface TransitionChildrenProps {
/** The kind of animation - "fade" | "slide" | "scale". Defaults to "slide" if direction is specified, else "scale". */
kind: AnimationKind
/** Whether the children are oriented horiontally or vertically. Defaults to "vertical" */
orientation: Orientation
/** The duration of the animation */
duration: number,
/** Either "forwards" or "backwards" */
direction: Direction
/** Whether to reset the scroll position to zero. Useful for full page animations. */
scrollToStart: boolean,
/** The animation threshold in pixels. Defaults to 5. */
animationThreshold: number
/** Whether width and height changes should be animated. Defaults to false. */
isSizeAnimated: boolean
}
Children will automatically move to their new positions if necessary.
There's three types of animation kind
, that determines what happens to entering and leaving elements:
slide
- slide in and outscale
- expand and collapsefade
- fade in and outIf kind
is not specified, then it defaults to slide
if direction
is specified, else scale
.
slide
is useful for carousel style animations on static lists. scale
is useful for animating dynamic lists where elements may be randomly inserted or removed.
Note you can use transitionChildren
in the case where there's only 1 child at a time - this is quite a common scenario.
Set scrollToStart
to true
when animating an element that represents a new page, as it's undesirable when the sliding stops to be scrolled part way into the new page.
FAQs
Solenya animation coordinates element animations in response to DOM changes.
We found that solenya-animation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.