2

I'm trying to transform a div by sliding it 200px to the right and then reducing it's scale by half. I'd like to slide THEN reduce the scale of the div, however I can't get the 2 transforms to operate independently, it slides and rescales at the same time. I thought that webkit-transition-delay would fix this problem, but it only ever applies the last delay specified (in this example 2s) to both transforms. Any thoughts?

.example-3-transform {
            -webkit-transform: translate(200px) scale(0.5);
            -webkit-transition-property: webkit-transition-translate, webkit-transition-scale;
            -webkit-transition-duration: 1s, 1s;
            -webkit-transition-timing-function: ease-in-out, ease-in-out; 
            -webkit-transition-delay: 0s, 2s;
}

1 Answer 1

9

You can use a keyframe for that:

@-webkit-keyframes myanim {

  50% { -webkit-transform: translate(200px) scale(1) }
  100% { -webkit-transform: translate(200px) scale(0.5) }

}

.example-3-transform { -webkit-animation: myanim 5s 1 ease-in-out forwards }

the parameters are:

  • 5s: duration of animation
  • 1: repetition
  • ease-in-out: timing algorithm, can also be linear, ease-in, ease-out, or cubic-bezier with custom parameters
  • forwards: will keep the style in desired state after animation finishes.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this created the desired effect!

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.