rootEnginear / svelte-action-motionone

Unofficial Svelte Action for Motion One animation library
https://www.npmjs.com/package/@rootenginear/svelte-action-motionone
MIT License
10 stars 0 forks source link

[RFC] Node callback for selector #3

Closed rootEnginear closed 1 week ago

rootEnginear commented 1 month ago

This idea is that, instead of passing a selector, you can pass a function that can accept the current node and then return the elements you want by yourself.

Before:

const listFadeOptions = {
    animate: {
        elements: '&>li',
        keyframes: {
            opacity: [0, 1]
        },
        options: {
            duration: 1,
            delay: stagger(0.1)
        }
    },
    options: {
        amount: 0.5
    }
};

After:

const listFadeOptions = {
    animate: {
        elements: (node) => node.children,
        keyframes: {
            opacity: [0, 1]
        },
        options: {
            duration: 1,
            delay: stagger(0.1)
        }
    },
    options: {
        amount: 0.5
    }
};

Pros

Cons

rootEnginear commented 1 week ago

Implemented in v0.5.0!