0

Is it possible to change something to get better performance of CSS animation: translate and opacity png file?

.chmura2 {
    top: 0px;
    left: -100%;
    animation: chmura2a ease-in-out 13s normal;
    -webkit-animation: chmura2a ease-in-out 13s normal;
    -webkit-transform: translateZ(0);
    background-image:url(chmura_pomar.png);
    -webkit-animation-fill-mode: forwards;
    animation-fill-mode: forwards;
}
@keyframes chmura2a {
    0% {
        transform: translate(0px, 0);
        opacity: 1;
        -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
        filter: opacity(100%);
        filter: alpha(opacity = 100);
    }
    30% {
        transform: translate(100%, 0);       
        opacity: 1;
        -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
        filter: opacity(100%);
        filter: alpha(opacity = 100);
    }
    56% {
        transform: translate(100%, 0);       
        opacity: 0;
        -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
        filter: opacity(0);
        filter: alpha(opacity = 0);
    }
    100% {
        transform: translate(250%, 0);       
        opacity: 0;
        filter: opacity(0);
        filter: alpha(opacity = 0);
        -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    }
}
@-webkit-keyframes chmura2a {
    0% {
        -webkit-transform: translate(0px, 0);
        -webkit-opacity: 1;
        opacity: 1;
        filter: opacity(100%);
        filter: alpha(opacity = 100);
        -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"
    }


..........................................
    }

I know that there is little mix with -webkit- and normal keyframe, but Internet Explorer sometimes is reading from -webkit sometimes from normal keyframe so I dubeled some commands.

4
  • You should be able to just use opacity (and not the filter versions) as all the latest browsers should support it Commented Jan 7, 2016 at 9:57
  • ... and older browsers don't support animations ... Commented Jan 7, 2016 at 10:03
  • You have also missed your closing bracket before your first keyframes: jsfiddle.net/0bmpfL0u Commented Jan 7, 2016 at 10:04
  • I've missed it at paste here. Thanks for Your answer. Should I use -webkit-keyframes too? Commented Jan 7, 2016 at 10:11

1 Answer 1

1

you could try adding will-change: opacity; to .chmura2 for hardware acceleration, although it's not supported by IE (yet).

Another option, although it's technically a hack, is to use a 3D transform, i.e. transform3d(0,0,0).

Sign up to request clarification or add additional context in comments.

3 Comments

Is there a different between transform3d(0,0,0) and transform: translateZ(0);?
I think that 'will-change: transform, opacity;' worked for chrome
You want to use a 3D transform as they're hardware accelerated. translateZ isn't I don't believe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.