An animation library, built on the Web Animations API for the smallest filesize and the fastest performance

Overview

motion-signals

A wrapper over Motion One, An animation library, built on the Web Animations API for the smallest filesize and the fastest performance. Works with solid-js

npm version npm Twitter Follow

Installation

npm install motion-signals motion

Functions

As of now, motion-signals has 2 Functions that wrap around animate and timeline of motion one respectively

Example usage

Things You could do with createAnimation

createAnimation List Example

createAnimation Counter Example

Things You could do with createTimeline

createTimeline Example Usage

createAnimation

Returns all the properties returned by animate and some helper functions and state

Props returned my animate are null initially

  • Item 1
  • Item 2
  • Item 3
); }">
function App() {
    const { play, getIsFinished, replay } = createAnimation(
        '.listItem',
        { y: -20, opacity: 1 },
        {
            delay: stagger(0.3),
            duration: 0.5,
            easing: [0.22, 0.03, 0.26, 1],
        },
    );

    // Play the animation on mount of the component
    onMount(() => {
        play();
    });

    return (
        // Replay the animation anytime by calling a function, anywhere
        <div class="App">
            <button disabled={!getIsFinished()} onClick={() => replay()}>
                Replay
            </button>

            <ul class="list">
                <li class="listItem">Item 1</li>
                <li class="listItem">Item 2</li>
                <li class="listItem">Item 3</li>
            </ul>
        </div>
    );
}

Instead of passing strings to select elements, you can also pass a ref 👇

let boxRef;
const { play, getIsFinished, replay } = createAnimation(
    () => boxRef, // Pass a Function that returns the ref
    { y: -20, scale: 1.2 },
    { duration: 1 },
);

return <div ref={boxRef}>BOX</div>;

API

const { play, replay, reset, getIsFinished, getAnimateInstance } = createAnimation(
    selector,
    keyframes,
    options,
    events,
);

createAnimation returns:

  • play: plays the animation
  • replay: Resets and plays the animation
  • reset: resets the element to its original styling
  • getIsFinished: is true when animation has finished playing
  • getAnimateInstance: Animation Controls. Refer to motion one docs for more.

createAnimation accepts:

  • selector - The target element, can be string or a ref

  • keyframes - Element will animate from its current style to those defined in the keyframe. Refer to motion's docs for more.

  • options - Optional parameter. Refer to motion doc's for the values you could pass to this.

  • events - Pass functions of whatever you want to happen when a event like onFinish happens.

    events usage example

    const { play, getIsFinished, replay } = createAnimation(
        '.listItem',
        { y: -20, opacity: 1 },
        {
            delay: stagger(0.3),
            duration: 0.5,
        },
        {
            onFinish: () => {
                // Whatever you want to do when animation finishes
            },
        },
    );

createTimeline

Create complex sequences of animations across multiple elements.

returns getTimelineInstance (Animation Controls) that are returned by timeline and some helper functions and state

Props returned by timeline are null initially

mind explosion gif

Tanvesh

@sarve__tanvesh

); }">
function App() {
    let gifRef;
    const { play, getIsFinished, replay } = createTimeline(
        [
            // You can use Refs too!
            [() => gifRef, { scale: [0, 1.2], opacity: 1 }],
            ['.heading', { y: [50, 0], opacity: [0, 1] }],
            ['.container p', { opacity: 1 }],
        ],
        { duration: 2 },
    );

    onMount(() => {
        play();
    });

    return (
        <div class="App">
            <button disabled={!getIsFinished()} onClick={() => replay()}>
                Replay
            </button>

            <div class="container">
                <img ref={gifRef} class="gif" src={Image} alt="mind explosion gif" />
                <div>
                    <h1 class="heading">Tanvesh</h1>
                    <p>@sarve__tanvesh</p>
                </div>
            </div>
        </div>
    );
}

API

const { play, replay, reset, getIsFinished, getTimelineInstance } = createTimeline(
    sequence,
    options,
    events,
);

createTimeline returns:

  • play: plays the animation
  • replay: Resets and plays the animation
  • reset: resets the element to its original styling
  • getIsFinished: is true when animation has finished playing
  • getTimelineInstance: Animation Controls. Refer to motion one docs for more.

createTimeline accepts:

  • sequence - sequence is an array, defines animations with the same settings as the animate function. In the arrays, Element can be either a string or a ref. You can refer to sequence docs for more on this.
  • options - Optional parameter. Refer to motion doc's for the values you could pass to this.
  • events - Pass functions of whatever you want to happen when a event like onFinish happens. Exactly same as createAnimation's onFinish.

Local Installation & Contributing

git clone https://github.com/:github-username/motion-signals.git
cd motion-signals
npm install # Installs dependencies for motion-signals
cd examples # React app to test out changes
npm install # Installs dependencies for example app
npm run dev # To run example on localhost:3000

The contributing guidelines along with local setup guide is mentioned in CONTRIBUTING.md

Any Type of feedback is more than welcome! This project is in very early stage and would love to have contributors of any skill/exp level.

You can contact me on my Twitter handle @Sarve___tanvesh

You might also like...

Playful and Colorful One-Page portfolio featuring Parallax effects and animations. Especially designers and/or photographers will love this theme! Built with MDX and Theme UI.

Gatsby Starter Portfolio: Cara Playful and Colorful One-Page portfolio featuring Parallax effects and animations. Using the Gatsby Theme @lekoarts/gat

Dec 24, 2021

Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno

Postgres.js - The Fastest full featured PostgreSQL client for Node.js and Deno

🚀 Fastest full-featured node & deno client 🏷 ES6 Tagged Template Strings at the core 🏄‍♀️ Simple surface API 🖊️ Dynamic query support 💬 Chat and

Jan 1, 2023

The fastest and tiniest utility for conditionally joining classNames.

The fastest and tiniest utility for conditionally joining classNames.

classix The fastest and tiniest utility for conditionally joining classNames. Installation npm install classix Usage Use any amount of string expressi

Dec 18, 2022

Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug prevention features.

Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug prevention features.

CryptoSniper Community Edition Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug preve

Nov 3, 2022

The world's fastest game! User gets ten dice. Then rolls and rolls as fast as they can until he gets all their dice on the same number.

tenzies-game The world's fastest game! User gets ten dice. Then rolls and rolls as fast as they can until he gets all their dice on the same number. I

Nov 26, 2022

CryptoDappy is the fastest way to get started with Flow.

CryptoDappy is the fastest way to get started with Flow.

Demo application (testnet) Learning hub (start learning here) What's CryptoDappy? CryptoDappy is the fastest way to get started with blockchain develo

Aug 18, 2022

The Omnibookmarks browser extension is the fastest way to open bookmarks

The Omnibookmarks browser extension is the fastest way to open bookmarks

★ Omnibookmarks The Omnibookmarks browser extension is the fastest way to open bookmarks. Just type a keyword into the address bar to quickly open or

Aug 20, 2022

The fastest way to get started with a fully-fledged web3 frontend

create-web3-frontend The fastest way to get started with a fully-fledged web3 frontend setup consisting of Next.js, wagmi and Tailwind CSS. npx create

Dec 28, 2022

The fastest growing marketing work management software.

The fastest growing marketing work management software.

Clone of coschedule.com This was our project for Unit-5 Construct week at Masai Shcool. Our target was to complete all main functionality of e-commerc

Jun 20, 2022
Comments
  • + /examples

    + /examples

    I added an examples folder using Solid-Start. Mostly translated from your motion-hooks example with minor tweaks, but all demos are presented in a single web page. Is OK on phones.

    Because of the extensive edits, I placed myself as co-contributor in the example only.

    motion-signals

    opened by tomByrer 2
  • github pages

    github pages

    The reason why I built the examples in #3 was for you to host on Github-pages, so people have a 'live' version ready to visit when the check out the repo.

    Should be enough tutorials online to help you. If you need more than that then I'll have to be co-admin, & might be better to put the repo in an org in that case.

    opened by tomByrer 1
  • Deletes User's Styles?

    Deletes User's Styles?

    Haven't tried the library, was just perusing the source code and saw this:

    https://github.com/tanvesh01/motion-signals/blob/aa35450e37c06015d866d64603dab48bfc266694/src/createAnimation/index.ts#L75

    I think this may be buggy if the user sets the style using the attribute themselves.

    opened by CoolOppo 0
  • Configure Renovate

    Configure Renovate

    Mend Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • package.json (npm)

    Configuration

    🔡 Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 5 Pull Requests:

    chore(deps): update dependency motion to ~10.6.1 || ~10.14.0
    • Schedule: ["at any time"]
    • Branch name: renovate/motion-10.x
    • Merge into: main
    • Upgrade motion to ~10.6.1 || ~10.14.0
    chore(deps): update dependency rollup-plugin-typescript2 to ^0.34.0
    • Schedule: ["at any time"]
    • Branch name: renovate/rollup-plugin-typescript2-0.x
    • Merge into: main
    • Upgrade rollup-plugin-typescript2 to ^0.34.0
    chore(deps): update dependency solid-js to ~1.3.3 || ~1.6.0
    • Schedule: ["at any time"]
    • Branch name: renovate/solid-js-1.x
    • Merge into: main
    • Upgrade solid-js to ~1.3.3 || ~1.6.0
    chore(deps): update dependency rollup to v3
    • Schedule: ["at any time"]
    • Branch name: renovate/rollup-3.x
    • Merge into: main
    • Upgrade rollup to ^3.0.0
    chore(deps): update jest monorepo to v29 (major)
    • Schedule: ["at any time"]
    • Branch name: renovate/major-jest-monorepo
    • Merge into: main
    • Upgrade jest to ^29.0.0
    • Upgrade ts-jest to ^29.0.0

    🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or spam the project. See docs for prhourlylimit for details.


    ❓ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by Mend Renovate. View repository job log here.

    opened by renovate[bot] 1
Owner
Tanvesh Sarve
20 / Frontend developer @wrky_ai / In love with React and JS / Web engineering / Love hip hop
Tanvesh Sarve
Animation library build on top of web animation API (WAAPI)

unanime.js Javascript animation library build on top of web animation API (WAAPI). Learn more about WAAPI: Web animation API Documentation Blog Daniel

Clément Laval 3 Jun 21, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components.

Chakra UI Animations Chakra UI Animations is a dependancy which offers you pre-built animations for your Chakra UI components. Installation yarn add @

Code Chemistry Inc. 9 Nov 19, 2022
The smallest CMS engine ever, made with ASP. NET Core and Dapper

TinyCMS The smallest CMS engine ever, made with ASP.NET Core and Dapper. Currently, only static content is supported, but adding new pages is as simpl

Marco Minerva 12 Dec 29, 2022
The 2Kb smallest Chat component.

tidi Meet tidi, the 2kb bubble chat component for any website... made using preact, running with a 4MB compiled backend service. FrontEnd Backend Disc

darker 72 Dec 11, 2022
I made countdown birthday and fireworks animation using HTML Canvas, CSS, JS. The fireworks animation gonna come out once the countdown is finished or in other words, "Birthday Time".

Countdown-Birthday-Fireworks-Animation I made countdown birthday and fireworks animation using HTML Canvas, CSS, JS. The fireworks animation gonna com

Mahardika Bayu S.B 19 Dec 31, 2022
A JavaScript animation plugin for menus. It creates a div that moves when you mouse over an element, giving it an elastic animation.

Lava-Lamp Description: A JavaScript animation plugin for menus. It creates a div that moves when you mouse over an element, giving it an elastic anima

Richard Hung 38 Jun 4, 2022
An efficient (and the fastest!) way to search the web privately using Brave Search Engine

Brave Search An efficient (and the fastest) way to search the web privately using Brave Search Engine. Not affiliated with Brave Search. Tested on Chr

Jishan Shaikh 7 Jun 2, 2022