Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blink animation in MUI

I am building a GatsbyJS site with MUI. Using the withStyles HOC, is it possible to make a blinking animation? I tried providing animation in styles:

const styles = theme => ({
        '@keyframes blinker': {
            from: {opacity: 1},
            to: {opacity: 0}
        },
        headerGT: {
            color: 'white',
            animation: ['blinker', '1s', 'linear', 'infinite'],
            '-webkit-animation': ['blinker', '1s', 'linear', 'infinite'],
            '-moz-animation': ['blinker', '1s', 'linear', 'infinite'],
        }
    })

I can see the class and keyframes gets recognized and headerGT has the animation method when the DOM is build, but the animation does not fire. Any ideas?

like image 732
stan.codes Avatar asked Sep 29 '18 13:09

stan.codes


People also ask

How many frames should a blink animation be?

Standard blink animation is usually about 8 frames, with the lids closed for about 2 frames, and an ease-in and ease-out at either end. Often you want to offset the eye lids by one frame. To see how to do it in detail, watch the short tutorial video below.

How do you make text blink in CSS?

Text Blinking feature can be done by animation property with blinking(any name), blink time, and up to blink time and @keyframes selector beside blinking(any name) same as given in animation and opacity property value.


1 Answers

I had the same problem but as specified in the JSS docs, referencing my animation with the $ prefix solved it.

Try this:

const style = theme => (
{
    '@keyframes blinker': {
        from: { opacity: 1 },
        to: { opacity: 0 },
    },
    headerGT: {
        [...]
        animationName: '$blinker',
        animationDuration: '1s',
        animationTimingFunction: 'linear',
        animationIterationCount: 'infinite',
    },
});
like image 60
rguerin Avatar answered Oct 05 '22 12:10

rguerin