npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-transitioner

v0.2.3

Published

# Overview A Svele/SvelteKit plugin that adds new hooks for customizing mount / unmount transitions.

Downloads

5

Readme

svelte-transitioner

Overview

A Svele/SvelteKit plugin that adds new hooks for customizing mount / unmount transitions.

Installation

yarn add svelte-transitioner

Description

  • Customize your own transitions with ease using custom hooks
  • Compatible with GSAP timelines
  • Synchromous transitions, no overlapping between previous Out with the current In transition

Usage

This plugin adds the following hooks:

  • onGlobalInit: a hook responsible for executing custom code when mounting any of the child components
  • onInit: a hook responsible for executing custom code on the current component
  • globalIntro: a hook that can execute the same custom transition when mounting any of the child components
  • intro: a hook that can execute a transition when mounting a component
  • globalOutro: a hook that can execute the same custom transition when unmounting any of the child components
  • outro: a hook that can execute a transition when unmounting a component

for the on*Init hooks, they will be called like the following:

onInit((node) => {
    // node is the current mounted node
})

as for the *intro or *outro callbacks, it can be used in two ways:

intro((node, t) => {
    // node is the current mounted node
    // t is the current transition animation
    // 1000 is the duration of the transition
}, 1000)

// Or you can use a GSAP Timeline callback instead, like the following
intro((node) => {
    const tl = gsap.timeline({
        paused: true
    })

    tl.to(node, {
        duration: 1,
        yPercent: -100,
    })

    return tl
})

One thing to keep in mind, in order for all the above hooks to work, we have to use some wrapper components:

  • TransitionLayout: this should be used in the parent components that will contains all the transitioned components.
  • Transitioner: this should be wrapped around the components that you want to apply transitions to.

So for example in a SvelteKit project, we can have the following:

/routes/__layout.svelte:

<script>
    import { onGlobalInit, globalIntro, globalOutro, TransitionLayout } from 'svelte-transitioner'

    onGlobalInit((node) => {

    })
    globalIntro((node) => {
        return gsap.timeline({ paused: true })
    })
    globalOutro((node, t) => {

    })
</script>
<TransitionLayout>
    <slot />
</TransitionLayout>

/routes/index.svelte:

<script>
    import { onInit, intro, outro, Transitioner } from 'svelte-transitioner'

    onInit((node) => {

    })
    intro((node) => {
        return gsap.timeline({ paused: true })
    })
    outro((node, t) => {

    })
</script>
<Transitioner>
    index
    <a href="/one">one.svelte</a>
</Transitioner>

/routes/one.svelte:

<script>
    import { onInit, intro, outro, Transitioner } from 'svelte-transitioner'

    onInit((node) => {

    })
    intro((node) => {
        return gsap.timeline({ paused: true })
    })
    outro((node, t) => {

    })
</script>
<Transitioner>
    One
    <a href="/">index.svelte</a>
</Transitioner>

TODO:

  • re-work repo examples
  • optimise
  • add some tests