Disable a transition while an animation is running

Roman Zino

Demo of the problem: https://jsfiddle.net/t0qsek8n/1/

<div class="test" id="test">Test text</div>
.test {
  position: relative;
  top: 0px;
  border: 1px solid #ccc;
  animation: test 5s;
  transition: top 1s;
}

@keyframes test {
  0% {
    opacity: 0;
    transition: none;
  }
  100% {
    opacity: 1;
    transition: none;
  }
}
const test = document.getElementById('test');
setTimeout(() => {
    test.style.top = "100px"
}, 1000);

I expect if the value of top property is changed by JS, transition transition: top 1000ms doesn't happen because of transition: none that provides @keyframes test, but actually, the transition happens. I cannot understand why transition value from keyframes doesn't override any existing definition for transition.

Temani Afif

let's take another example using display:

.test {
  position: relative;
  top: 0px;
  border: 1px solid #ccc;
  animation: test 5s forwards;
}

@keyframes test {
  0% {
    opacity: 0;
    display: none;
  }
  100% {
    opacity: 1;
    display: none;
  }
}
<div class="test" id="test">
  Test text
</div>

We logically expect to never see the element since we set display:none and we made the animation to be forwards but display is simply ignored because it cannot be animated. Same logic with transition since it's a property that we cannot animate ref.

Basically, any property that cannot be animated will simply get ignored when used with keyframes.

Properties that aren't specified in every keyframe are interpolated if possible — properties that can't be interpolated are dropped from the animation. ref

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Disable animation of mat-stepper while in transition

Disable transition animation

Disable the animation/transition on the mobile

How to disable touch detection while Google Map animation is running in android

Disable Transition Animation Between Activities

Animation transition not running at first click

Transition animation scale does not disable animation inside application

How to disable hover effect for the transition or animation time then enable it after the transition or animation is finished in css?

Disable smooth animation transition of Bootstrap Progress Bar on certain percent

How to disable transition animation when reduce motion is turned off

Android: disable content transition animation if API level is under 21

How to disable page transition animation in Ionic 4 / Angular?

React Native Native-Stack: disable transition animation on iOS

Disable UITabBarController animation while setting rootViewContorller

Disable ontouch listener while the gif animation is playing

Circular animation speeds up after running a while

Force jQuery to change animation while running

PictureBox animation freezing while Task running

CSS animation appear on top while running

OnClick doesnt work while Animation is running

Temporarily Disable a DIV while setInterval is running

how to disable phone keyboard while app is running?

How to disable Button while AsyncTask is running? (Android)

How to disable(deactivate) button while program is running?

Python Tkinter disable button while function is running

Disable a JS function while another function is running

How can I transition between two nuxt pages, while first waiting on a child component transition/animation to finish?

How can I use animation/animation not running during a Hero transition in Flutter?

How to disable page animation while loading in WP 8.1?