All Projects → shiryel → saos

shiryel / saos

Licence: MIT license
Svelte Animation on Scroll - A small component to make your CSS animations work on scroll with Svelte

Programming Languages

Svelte
593 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
Nix
1067 projects
HTML
75241 projects

Projects that are alternatives of or similar to saos

svelte-portal
Svelte component for rendering outside the DOM of parent component
Stars: ✭ 261 (+65.19%)
Mutual labels:  svelte3
svelte-meteor-data
Reactively track Meteor data inside Svelte components
Stars: ✭ 14 (-91.14%)
Mutual labels:  svelte3
svelte-interview-questions
Concepts and Questions related to Svelte - Part of official Svelte resources list
Stars: ✭ 18 (-88.61%)
Mutual labels:  svelte3
perfect-home
firefox newtab/home replacement
Stars: ✭ 101 (-36.08%)
Mutual labels:  svelte3
mmss-client
No description or website provided.
Stars: ✭ 16 (-89.87%)
Mutual labels:  svelte3
svelte-click-outside
A wrapper component that provides click outside detection
Stars: ✭ 28 (-82.28%)
Mutual labels:  svelte3
svelte-inview
A Svelte action that monitors an element enters or leaves the viewport.🔥
Stars: ✭ 358 (+126.58%)
Mutual labels:  svelte3
hacker-feud
💥 A single page web game made with Svelte.
Stars: ✭ 61 (-61.39%)
Mutual labels:  svelte3
svelte-starter-kit
Svelte with brilliant bells and useful whistles
Stars: ✭ 384 (+143.04%)
Mutual labels:  svelte3
svelte-webcomponents
A ready-to-use project template to build custom elements (web components) with Svelte 3 with support and examples for web components, jest, sass, nested components with props, eslinting, stylelinting, Github actions, propagating custom events from shadow-DOM to real-DOM etc.
Stars: ✭ 22 (-86.08%)
Mutual labels:  svelte3
svelte-loader-hot
Webpack loader for svelte components with HMR support
Stars: ✭ 22 (-86.08%)
Mutual labels:  svelte3
svelte-accessible-dialog
An accessible dialog component for Svelte apps
Stars: ✭ 24 (-84.81%)
Mutual labels:  svelte3
svelte-spinkit
A collection of loading indicators animated with CSS for Svelte
Stars: ✭ 27 (-82.91%)
Mutual labels:  svelte3
svelte-writable-derived
Two-way data-transforming stores for Svelte
Stars: ✭ 65 (-58.86%)
Mutual labels:  svelte3
ui-svelte
A component library for Svelte
Stars: ✭ 18 (-88.61%)
Mutual labels:  svelte3
BeatHub
Small, simple, and fast custom beatmap browser & downloader built with Svelte
Stars: ✭ 13 (-91.77%)
Mutual labels:  svelte3
svelte-headlessui
Unofficial Svelte port of Headless UI components
Stars: ✭ 564 (+256.96%)
Mutual labels:  svelte3
echarts-for-svelte
📈 Baidu Echarts(v3.0 & v4.0) components for Svelte wrapper.
Stars: ✭ 25 (-84.18%)
Mutual labels:  svelte3
Svelte Material Ui
Svelte Material UI Components
Stars: ✭ 2,081 (+1217.09%)
Mutual labels:  svelte3
svelte-form
JSON Schema form for Svelte v3
Stars: ✭ 47 (-70.25%)
Mutual labels:  svelte3

Svelte Animation on Scroll

Publish on NPM NPM version Code Size npm LICENSE

Twitter

A very small svelte component to animate your elements on scroll

SAoS allows you to animate once or multiple times a element on scroll, you can define the top and bottom "triggers" and the css of the internal divs (not recomended, but can help in some cases), see below the demo, how install and some examples 😸

In terms of performance, this lib uses the Intersection Observer for most of the browsers (shame on you Internet Explorer)

Demo


How to install

  • Npm
npm i saos --save-dev
  • Yarn
yarn add -D saos

Note: Sapper only supports libs as DEV dependencies, if you realy want to use this lib as a normal dependency on Sapper make sure to import like this import Saos from 'saos/src/Saos.svelte'; or otherwise you will have problems with SSR!

How to use

Basic usage:

  • First import the package on Svelte
import Saos from "saos";
  • Then define your @keyframes animation as a -global- on svelte
@keyframes -global-from-left {
  0% {
    transform: rotateX(50deg) translateX(-200vw) skewX(-50deg);
    opacity: 1;
  }
  100% {
    transform: rotateX(0deg) translateX(0) skewX(0deg);
    opacity: 1;
  }
}
  • Finally add the keyframe name without the -global- and the others animations params
<Saos animation={"from-left 4s cubic-bezier(0.35, 0.5, 0.65, 0.95) both"}>
  <div><p>animation: from-left</p></div>
</Saos>

Beyond the animation param, you can use:

  • animation_out -> to play a animation when the element is no more "visible" (use the top and bottom to define this), default: "none; opacity: 0"
  • once -> if the animation will be played only one time or multiple times, default: false
  • top -> the top of the observer, use a positive value to play the animation after top be visible, default: 0
  • bottom -> the bottom of the observer, use a positive value to play the animation after bottom be visible, default: 0
  • css_observer -> the css of the div that is the observer, not recomended to use, but is here 🐈, default: ""
  • css_animation -> the css of the div that is the animation, not recomended to use, but is here 🐈, default: ""

And we have reactive dispatchs too!

You can do something like:

// Create a handler on your script

function handleObserver(x) {
  console.info(x.detail.observing);
}

// Use the `update` event on your html that will be dispatched every time that the `observing` update!

<Saos on:update={handleObserver}>...</Saos>

And it will work! Amazing no? take a look at the last card on our demo

And you can see a bunch of usage here

If you are lazy (like me) to create your own animations, take a look at animista

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].