CSS animation doesn't restart when resetting classsetTimeout with 0ms needed to remove animation classRestart animation in CSS3: any better way than removing the element?CSS3 animation resetRestart css transition via jQuery or javascriptCSS3 & Jquery Animation - Repeat after some secondsHow to run the same animation when switching classes without JavaScriptRestart CSS3 animation after it's stoppedWhich characters are valid in CSS class names/selectors?When to use IMG vs. CSS background-image?Can a CSS class inherit one or more other classes?How to remove all CSS classes using jQuery/JavaScript?CSS selector for first element with classwildcard * in CSS for classesWhat is the difference between Normalize.css and Reset CSS?Reset/remove CSS styles for element only
How to evaluate math equation, one per line in a file?
Why do HK chefs use a white cloth to clutch wok?
How can I offer my prayers to an atheist?
What is the quickest way to raise Affection?
Exactly what color was the text on monochrome terminals with green-on-black and amber-on-black screens?
Help me pair my socks
What are the units of the product of two signals?
What is the largest piece of space debris volumetrically?
Why is it ethical for Ambassador Sondland to have been given an ambassadorship for campaign contributions?
A New Math Operation?
How can you weaponize a thermos?
Simulate reproduction in a population of oozes
Contacted by head of school regarding an issue - should I be worried?
My professor changed a take-home test to an in-class test with no notice. Can I fight the grade?
Is there a sonic boom when flying nearby?
Where should I search for computations of group cohomology rings of not-too-complicated finite groups?
Threatening to discontinue a service for a client
Pointlessly recurse down the alphabet
A Ukrainian idiom meaning "on one's last legs"
How to pass Collection of exceptions as a root cause?
How can I understand references in Seneca's Moral letters to Lucilius?
Suppose I capture encrypted data that I want to decrypt. Could I use a server farm to decrypt?
Dollar cost averaging vs buy low/sell high
If password expiration is applied, should door-lock expiration be applied too?
CSS animation doesn't restart when resetting class
setTimeout with 0ms needed to remove animation classRestart animation in CSS3: any better way than removing the element?CSS3 animation resetRestart css transition via jQuery or javascriptCSS3 & Jquery Animation - Repeat after some secondsHow to run the same animation when switching classes without JavaScriptRestart CSS3 animation after it's stoppedWhich characters are valid in CSS class names/selectors?When to use IMG vs. CSS background-image?Can a CSS class inherit one or more other classes?How to remove all CSS classes using jQuery/JavaScript?CSS selector for first element with classwildcard * in CSS for classesWhat is the difference between Normalize.css and Reset CSS?Reset/remove CSS styles for element only
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I am using CSS shader + animation. My shader class is defined as follows:
.shader
-webkit-filter :custom(url(v.vs) mix(url(f.fs) multiply destination-over), 200 200);
-webkit-animation-name: test;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1
I am trying to set/unset the styles(shader+animation) dynamically using jquery through $('#holder').addClass('shader');
and $('#holder').removeClass('shader');
However, the weird thing is when I reset the class (e.g., calling addClass after removeClass), only the shader gets reapplied but the animation doesn't (I have hooked the AnimationStart event to see when my animation starts). Anyone know why this is the case and how I can solve it?
Edit:
I added a simplified version of JSfiddle snippet here. Essentially I'm re-applying the animation to a div twice but the actual animation only gets called the first time.
javascript jquery css css3 webkit
|
show 1 more comment
I am using CSS shader + animation. My shader class is defined as follows:
.shader
-webkit-filter :custom(url(v.vs) mix(url(f.fs) multiply destination-over), 200 200);
-webkit-animation-name: test;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1
I am trying to set/unset the styles(shader+animation) dynamically using jquery through $('#holder').addClass('shader');
and $('#holder').removeClass('shader');
However, the weird thing is when I reset the class (e.g., calling addClass after removeClass), only the shader gets reapplied but the animation doesn't (I have hooked the AnimationStart event to see when my animation starts). Anyone know why this is the case and how I can solve it?
Edit:
I added a simplified version of JSfiddle snippet here. Essentially I'm re-applying the animation to a div twice but the actual animation only gets called the first time.
javascript jquery css css3 webkit
2
Did you try keeping the animation properties in a separate class that is never removed?
– bfavaretto
Apr 17 '13 at 3:31
mmmm no but I don't think that would help, since I only have 1 iteration and I call removeClass after the animationEnd event
– Discombobulous
Apr 17 '13 at 3:46
Can you post a jsFiddle so we can have a better look
– apaul
Apr 17 '13 at 3:53
An example of the animation/filter in action might help.
– Bernie
Apr 17 '13 at 3:57
1
Possible duplicate of Restart animation in CSS3: any better way than removing the element?
– Vivek Maharajh
Jun 29 '16 at 3:16
|
show 1 more comment
I am using CSS shader + animation. My shader class is defined as follows:
.shader
-webkit-filter :custom(url(v.vs) mix(url(f.fs) multiply destination-over), 200 200);
-webkit-animation-name: test;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1
I am trying to set/unset the styles(shader+animation) dynamically using jquery through $('#holder').addClass('shader');
and $('#holder').removeClass('shader');
However, the weird thing is when I reset the class (e.g., calling addClass after removeClass), only the shader gets reapplied but the animation doesn't (I have hooked the AnimationStart event to see when my animation starts). Anyone know why this is the case and how I can solve it?
Edit:
I added a simplified version of JSfiddle snippet here. Essentially I'm re-applying the animation to a div twice but the actual animation only gets called the first time.
javascript jquery css css3 webkit
I am using CSS shader + animation. My shader class is defined as follows:
.shader
-webkit-filter :custom(url(v.vs) mix(url(f.fs) multiply destination-over), 200 200);
-webkit-animation-name: test;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: 1
I am trying to set/unset the styles(shader+animation) dynamically using jquery through $('#holder').addClass('shader');
and $('#holder').removeClass('shader');
However, the weird thing is when I reset the class (e.g., calling addClass after removeClass), only the shader gets reapplied but the animation doesn't (I have hooked the AnimationStart event to see when my animation starts). Anyone know why this is the case and how I can solve it?
Edit:
I added a simplified version of JSfiddle snippet here. Essentially I'm re-applying the animation to a div twice but the actual animation only gets called the first time.
javascript jquery css css3 webkit
javascript jquery css css3 webkit
edited Apr 17 '13 at 4:22
Discombobulous
asked Apr 17 '13 at 3:24
DiscombobulousDiscombobulous
7731 gold badge9 silver badges20 bronze badges
7731 gold badge9 silver badges20 bronze badges
2
Did you try keeping the animation properties in a separate class that is never removed?
– bfavaretto
Apr 17 '13 at 3:31
mmmm no but I don't think that would help, since I only have 1 iteration and I call removeClass after the animationEnd event
– Discombobulous
Apr 17 '13 at 3:46
Can you post a jsFiddle so we can have a better look
– apaul
Apr 17 '13 at 3:53
An example of the animation/filter in action might help.
– Bernie
Apr 17 '13 at 3:57
1
Possible duplicate of Restart animation in CSS3: any better way than removing the element?
– Vivek Maharajh
Jun 29 '16 at 3:16
|
show 1 more comment
2
Did you try keeping the animation properties in a separate class that is never removed?
– bfavaretto
Apr 17 '13 at 3:31
mmmm no but I don't think that would help, since I only have 1 iteration and I call removeClass after the animationEnd event
– Discombobulous
Apr 17 '13 at 3:46
Can you post a jsFiddle so we can have a better look
– apaul
Apr 17 '13 at 3:53
An example of the animation/filter in action might help.
– Bernie
Apr 17 '13 at 3:57
1
Possible duplicate of Restart animation in CSS3: any better way than removing the element?
– Vivek Maharajh
Jun 29 '16 at 3:16
2
2
Did you try keeping the animation properties in a separate class that is never removed?
– bfavaretto
Apr 17 '13 at 3:31
Did you try keeping the animation properties in a separate class that is never removed?
– bfavaretto
Apr 17 '13 at 3:31
mmmm no but I don't think that would help, since I only have 1 iteration and I call removeClass after the animationEnd event
– Discombobulous
Apr 17 '13 at 3:46
mmmm no but I don't think that would help, since I only have 1 iteration and I call removeClass after the animationEnd event
– Discombobulous
Apr 17 '13 at 3:46
Can you post a jsFiddle so we can have a better look
– apaul
Apr 17 '13 at 3:53
Can you post a jsFiddle so we can have a better look
– apaul
Apr 17 '13 at 3:53
An example of the animation/filter in action might help.
– Bernie
Apr 17 '13 at 3:57
An example of the animation/filter in action might help.
– Bernie
Apr 17 '13 at 3:57
1
1
Possible duplicate of Restart animation in CSS3: any better way than removing the element?
– Vivek Maharajh
Jun 29 '16 at 3:16
Possible duplicate of Restart animation in CSS3: any better way than removing the element?
– Vivek Maharajh
Jun 29 '16 at 3:16
|
show 1 more comment
7 Answers
7
active
oldest
votes
The problem is that, even though you remove and then re-apply the animated class, you do this in the course of a single, blocking function. When your function exits, it appears to the rendering engine that nothing has changed.
One solution (the one that you chose), is to clone the element and destroy the original. This is fine, but if you had any event bindings to the original element (i think) they they will be destroyed too.
Another approach is to remove the animated class from the element, and then wrap the code that re-applies the class inside of a setTimeout() call with a very small delay, e.g.
$('#holder').removeClass('shader');
setTimeout(
function()$('#holder').addClass('shader')
, 1);
I've tweaked your jsfiddle to use this approach: http://jsfiddle.net/HuFBN/7/
2
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
add a comment
|
I think I figured it out. According to this, css animation can't get applied to the same node twice (even if you have a different animation!). So I had to clone the node, remove the original, and add back the cloned node.
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
add a comment
|
According to a 2011 article on css-tricks.com, triggering a reflow in between removing and adding the class will restart the animation. Example (verbose):
$('#holder').removeClass('shader');
$('#holder').offsetWidth = $('#holder').offsetWidth; // triggers reflow
$('#holder').addClass('shader'); // restarts animation
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
add a comment
|
You need to recreate your element.
function resetAnimation(jqNode)
var clone = jqNode.clone();
jqNode.after( clone );
jqNode.remove();
jqNode[0] = clone[0];
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
add a comment
|
Try using this just after you apply the animation - given that "e" is your animated element:
e.outerHTML = e.outerHTML;
add a comment
|
You definitely have to remove class that contains animation and then add it again. It should also work without .offsetWidth
. It worked for me. So
$('#id').removeClass('animationClass');
$('#id').addClass('animationClass'); // starts animation again
should do the trick.
add a comment
|
way to trigger a reflow:
element.classList.remove("class");
element.scrollBy(0, 0);
element.classList.add("class");
works in strict mode!
doesn't require a write operation on a read-only value!
doesn't require a whole new function!
one line and go! :)
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16050914%2fcss-animation-doesnt-restart-when-resetting-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that, even though you remove and then re-apply the animated class, you do this in the course of a single, blocking function. When your function exits, it appears to the rendering engine that nothing has changed.
One solution (the one that you chose), is to clone the element and destroy the original. This is fine, but if you had any event bindings to the original element (i think) they they will be destroyed too.
Another approach is to remove the animated class from the element, and then wrap the code that re-applies the class inside of a setTimeout() call with a very small delay, e.g.
$('#holder').removeClass('shader');
setTimeout(
function()$('#holder').addClass('shader')
, 1);
I've tweaked your jsfiddle to use this approach: http://jsfiddle.net/HuFBN/7/
2
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
add a comment
|
The problem is that, even though you remove and then re-apply the animated class, you do this in the course of a single, blocking function. When your function exits, it appears to the rendering engine that nothing has changed.
One solution (the one that you chose), is to clone the element and destroy the original. This is fine, but if you had any event bindings to the original element (i think) they they will be destroyed too.
Another approach is to remove the animated class from the element, and then wrap the code that re-applies the class inside of a setTimeout() call with a very small delay, e.g.
$('#holder').removeClass('shader');
setTimeout(
function()$('#holder').addClass('shader')
, 1);
I've tweaked your jsfiddle to use this approach: http://jsfiddle.net/HuFBN/7/
2
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
add a comment
|
The problem is that, even though you remove and then re-apply the animated class, you do this in the course of a single, blocking function. When your function exits, it appears to the rendering engine that nothing has changed.
One solution (the one that you chose), is to clone the element and destroy the original. This is fine, but if you had any event bindings to the original element (i think) they they will be destroyed too.
Another approach is to remove the animated class from the element, and then wrap the code that re-applies the class inside of a setTimeout() call with a very small delay, e.g.
$('#holder').removeClass('shader');
setTimeout(
function()$('#holder').addClass('shader')
, 1);
I've tweaked your jsfiddle to use this approach: http://jsfiddle.net/HuFBN/7/
The problem is that, even though you remove and then re-apply the animated class, you do this in the course of a single, blocking function. When your function exits, it appears to the rendering engine that nothing has changed.
One solution (the one that you chose), is to clone the element and destroy the original. This is fine, but if you had any event bindings to the original element (i think) they they will be destroyed too.
Another approach is to remove the animated class from the element, and then wrap the code that re-applies the class inside of a setTimeout() call with a very small delay, e.g.
$('#holder').removeClass('shader');
setTimeout(
function()$('#holder').addClass('shader')
, 1);
I've tweaked your jsfiddle to use this approach: http://jsfiddle.net/HuFBN/7/
answered May 17 '13 at 23:42
NobodyManNobodyMan
2,1222 gold badges26 silver badges35 bronze badges
2,1222 gold badges26 silver badges35 bronze badges
2
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
add a comment
|
2
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
2
2
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This is the correct answer. Extra points go for explaining why this hack is needed ("When your function exits, it appears to the rendering engine that nothing has changed").
– Agoston Horvath
Jul 10 '14 at 9:47
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
This worked for me. What I also like about it this too is that you can easily adjust the delay in this approach as when it should start again. thanks!
– klewis
Nov 10 '15 at 17:18
add a comment
|
I think I figured it out. According to this, css animation can't get applied to the same node twice (even if you have a different animation!). So I had to clone the node, remove the original, and add back the cloned node.
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
add a comment
|
I think I figured it out. According to this, css animation can't get applied to the same node twice (even if you have a different animation!). So I had to clone the node, remove the original, and add back the cloned node.
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
add a comment
|
I think I figured it out. According to this, css animation can't get applied to the same node twice (even if you have a different animation!). So I had to clone the node, remove the original, and add back the cloned node.
I think I figured it out. According to this, css animation can't get applied to the same node twice (even if you have a different animation!). So I had to clone the node, remove the original, and add back the cloned node.
answered Apr 17 '13 at 5:19
DiscombobulousDiscombobulous
7731 gold badge9 silver badges20 bronze badges
7731 gold badge9 silver badges20 bronze badges
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
add a comment
|
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
Different animations certainly work in Chrome.
– dmi3y
May 23 '17 at 17:20
add a comment
|
According to a 2011 article on css-tricks.com, triggering a reflow in between removing and adding the class will restart the animation. Example (verbose):
$('#holder').removeClass('shader');
$('#holder').offsetWidth = $('#holder').offsetWidth; // triggers reflow
$('#holder').addClass('shader'); // restarts animation
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
add a comment
|
According to a 2011 article on css-tricks.com, triggering a reflow in between removing and adding the class will restart the animation. Example (verbose):
$('#holder').removeClass('shader');
$('#holder').offsetWidth = $('#holder').offsetWidth; // triggers reflow
$('#holder').addClass('shader'); // restarts animation
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
add a comment
|
According to a 2011 article on css-tricks.com, triggering a reflow in between removing and adding the class will restart the animation. Example (verbose):
$('#holder').removeClass('shader');
$('#holder').offsetWidth = $('#holder').offsetWidth; // triggers reflow
$('#holder').addClass('shader'); // restarts animation
According to a 2011 article on css-tricks.com, triggering a reflow in between removing and adding the class will restart the animation. Example (verbose):
$('#holder').removeClass('shader');
$('#holder').offsetWidth = $('#holder').offsetWidth; // triggers reflow
$('#holder').addClass('shader'); // restarts animation
answered Jun 6 '14 at 15:04
fekleefeklee
6,6948 gold badges43 silver badges64 bronze badges
6,6948 gold badges43 silver badges64 bronze badges
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
add a comment
|
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
Apparently this breaks in javascript strict mode.
– Adam
Sep 5 '14 at 1:36
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
@Adam I don't see how this breaks strict mode. Do you have more details?
– feklee
Sep 8 '14 at 13:45
add a comment
|
You need to recreate your element.
function resetAnimation(jqNode)
var clone = jqNode.clone();
jqNode.after( clone );
jqNode.remove();
jqNode[0] = clone[0];
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
add a comment
|
You need to recreate your element.
function resetAnimation(jqNode)
var clone = jqNode.clone();
jqNode.after( clone );
jqNode.remove();
jqNode[0] = clone[0];
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
add a comment
|
You need to recreate your element.
function resetAnimation(jqNode)
var clone = jqNode.clone();
jqNode.after( clone );
jqNode.remove();
jqNode[0] = clone[0];
You need to recreate your element.
function resetAnimation(jqNode)
var clone = jqNode.clone();
jqNode.after( clone );
jqNode.remove();
jqNode[0] = clone[0];
answered Oct 9 '15 at 19:24
Deni35Deni35
2,1081 gold badge17 silver badges24 bronze badges
2,1081 gold badge17 silver badges24 bronze badges
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
add a comment
|
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
It's a very useful method to reset animations also. Thanks.
– sentenza
Nov 11 '16 at 13:25
add a comment
|
Try using this just after you apply the animation - given that "e" is your animated element:
e.outerHTML = e.outerHTML;
add a comment
|
Try using this just after you apply the animation - given that "e" is your animated element:
e.outerHTML = e.outerHTML;
add a comment
|
Try using this just after you apply the animation - given that "e" is your animated element:
e.outerHTML = e.outerHTML;
Try using this just after you apply the animation - given that "e" is your animated element:
e.outerHTML = e.outerHTML;
answered Apr 29 '15 at 15:14
ElDoRado1239ElDoRado1239
2,6912 gold badges12 silver badges12 bronze badges
2,6912 gold badges12 silver badges12 bronze badges
add a comment
|
add a comment
|
You definitely have to remove class that contains animation and then add it again. It should also work without .offsetWidth
. It worked for me. So
$('#id').removeClass('animationClass');
$('#id').addClass('animationClass'); // starts animation again
should do the trick.
add a comment
|
You definitely have to remove class that contains animation and then add it again. It should also work without .offsetWidth
. It worked for me. So
$('#id').removeClass('animationClass');
$('#id').addClass('animationClass'); // starts animation again
should do the trick.
add a comment
|
You definitely have to remove class that contains animation and then add it again. It should also work without .offsetWidth
. It worked for me. So
$('#id').removeClass('animationClass');
$('#id').addClass('animationClass'); // starts animation again
should do the trick.
You definitely have to remove class that contains animation and then add it again. It should also work without .offsetWidth
. It worked for me. So
$('#id').removeClass('animationClass');
$('#id').addClass('animationClass'); // starts animation again
should do the trick.
answered Jun 10 '17 at 23:03
M BrankM Brank
1591 gold badge1 silver badge5 bronze badges
1591 gold badge1 silver badge5 bronze badges
add a comment
|
add a comment
|
way to trigger a reflow:
element.classList.remove("class");
element.scrollBy(0, 0);
element.classList.add("class");
works in strict mode!
doesn't require a write operation on a read-only value!
doesn't require a whole new function!
one line and go! :)
add a comment
|
way to trigger a reflow:
element.classList.remove("class");
element.scrollBy(0, 0);
element.classList.add("class");
works in strict mode!
doesn't require a write operation on a read-only value!
doesn't require a whole new function!
one line and go! :)
add a comment
|
way to trigger a reflow:
element.classList.remove("class");
element.scrollBy(0, 0);
element.classList.add("class");
works in strict mode!
doesn't require a write operation on a read-only value!
doesn't require a whole new function!
one line and go! :)
way to trigger a reflow:
element.classList.remove("class");
element.scrollBy(0, 0);
element.classList.add("class");
works in strict mode!
doesn't require a write operation on a read-only value!
doesn't require a whole new function!
one line and go! :)
answered Mar 28 at 22:04
TwistedTamarinTwistedTamarin
611 bronze badge
611 bronze badge
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16050914%2fcss-animation-doesnt-restart-when-resetting-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Did you try keeping the animation properties in a separate class that is never removed?
– bfavaretto
Apr 17 '13 at 3:31
mmmm no but I don't think that would help, since I only have 1 iteration and I call removeClass after the animationEnd event
– Discombobulous
Apr 17 '13 at 3:46
Can you post a jsFiddle so we can have a better look
– apaul
Apr 17 '13 at 3:53
An example of the animation/filter in action might help.
– Bernie
Apr 17 '13 at 3:57
1
Possible duplicate of Restart animation in CSS3: any better way than removing the element?
– Vivek Maharajh
Jun 29 '16 at 3:16