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-class-transition

v1.0.4

Published

A very simple Svelte 3 component that allows you to do transition using CSS classes

Downloads

1,187

Readme

svelte-class-transition

svelte-class-transition is a very simple Svelte 3 component that allows you to do transitions using CSS classes.

You can find multiple examples with different use cases here: https://svelte-class-transition-examples.now.sh/

Install

Using yarn:

yarn add svelte-class-transition

Using npm:

npm install svelte-class-transition

Usage

Implementation

Here's how it should be used:

<script>
    import Transition from 'svelte-class-transition';

    export let toggle;
</script>

<Transition
    {toggle}
    transitions="transition transform"
    inTransition="ease-out duration-1000"
    inState="opacity-0 -translate-x-16"
    onState="opacity-100 translate-x-0"
    outState="opacity-0 translate-x-16"
    outTransition="ease-in duration-1000"
>
    <!-- All the classes will be applied to the slot's main element, in this case, the div below -->
    <div>
        ...
    </div>
</Transition>

Props

svelte-class-transition has several props for different use cases. All of them are optionnal but without any, the component won't do anything.

toggle

Type: boolean | undefined

Default value: undefined

The toggle property is where you'll store your toggling variable. If set to true the slot will be first visible, if set to false it will start hidden, you should note that there is no animation for the first state. On change of the property, the slot will animate according to the other props.

There is a possiblity to not set this property:

  • If the component has a parent (or grand*-parent) transition component, it will listen to its changes and react according to them. The parent (or grand*-parent) transition component will wait until all the animations are finished before being hidden.
  • If the component doesn't have a parent (or grand*-parent) transition component, it will show the slot with an animation once the DOM has fully loaded.

inState

Type: string

Default value: ''

The inState property is the state from which the slot while come from when setting the toggle to true. If you want your component to go from opacity-0 to opacity-100, you should set inState to opacity-0.

onState

Type: string

Default value: ''

The onState property is the state from which the slot while go to when setting the toggle to true. If you want your component to go from opacity-0 to opacity-100, you should set onState to opacity-100.

outState

Type: string

Default value: inState

The outState property is the state from which the slot while go to when setting the toggle to false. If you want your component to go from opacity-100 to opacity-0, you should set outState to opacity-0. If you want the same inState and outState, you can skip this prop.

inTransition

Type: string

Default value: ''

The inTransition property is the transition the slot will use after toggle has been set to true. You'll want to set here the transition, the easing, the duration and eventually the delay. For example it could be: transition ease-out duration-300.

outTransition

Type: string

Default value: inTransition

The outTransition property is the transition the slot will use after toggle has been set to false. You'll want to set here the transition, the easing, the duration and eventually the delay. For example it could be: transform ease-in duration-200. If you want the same inTransition and outTransition, you can skip this prop.

transitions

Type: string

Default value: ''

The transitions property is where you'll regroup your common classes from inTranstion and outTransition, like for example the transition property. It's totally optionnal and doesn't change anything inside the component, it's here to make your code look cleaner.

offVisible

Type: boolean

Default value: false

The offVisible property is where you'll define if the slot should be hidden when off or not.