Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass params in animation functions #49

Open
lbineau opened this issue Jul 13, 2016 · 0 comments
Open

Pass params in animation functions #49

lbineau opened this issue Jul 13, 2016 · 0 comments

Comments

@lbineau
Copy link

lbineau commented Jul 13, 2016

Hi, thanks for your library I use it on several projects, it is already a big improvement compare to the CSS version.
I would want to go further and be able to customize animation functions. (https://www.sitepoint.com/using-sass-maps/#module-configuration)
Something like this (not tested though):

// in animate.scss files
@include keyframes(fadeInRightBig, $options: ()) {
    $configuration: map-merge((
        tx: 2000px,
    ), $options);
    0% {
        opacity: 0;
        @include transform(translateX(map-get($configuration, tx)));
    }
    100% {
        opacity: 1;
        @include transform(translateX(0));
    }
}
// in user scss file
.description {
    @include fadeInRightBig($duration: 1s, /* any other params, then the options to be forward to the animation itself */ $options: (tx: 100%));
}

For now I override the animation locally like the following but it feels wrong because it overrides the function for every later uses

// in user scss file
@include keyframes(fadeInRightBig) {
    0% {
        opacity: 0;
        @include transform(translateX(100%));
    }
    100% {
        opacity: 1;
        @include transform(translateX(0));
    }
}
.description {
    @include fadeInRightBig($duration: 1s);
}

What do you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant