twitwi / deck.js

Better Modern HTML Presentations
http://home.heeere.com/tech-deckjs-ext.html
MIT License
36 stars 8 forks source link

Explore issue and possible solution for attribute animation #11

Open twitwi opened 7 years ago

twitwi commented 7 years ago

Basically one can walk once through the slides without problems, but then going back and forward again, leads to the situtation that one is stuck on the previous slide and page forward does not work anymore.

Exhibiting the issue:

--- a/samples/deck-svg.html
+++ b/samples/deck-svg.html
@@ -300,11 +300,11 @@
     <!--div class="anim-attribute slide" data-what=".svg1 svg, .svg2 svg" data-attr="svgViewBox:110 120.5 17 17"></div not fully working (jquerysvg pb?) -->
     <div class="anim-viewboxas slide" data-what=".svg1 svg, .svg2 svg" data-as="#zoomBox1"></div>
     <div class="anim-attribute anim-continue slide" data-what=".svg1 #circleRedStar>*" data-attr="svgStroke: red"></div>
-    <div class="anim-attribute slide" data-what=".svg1 #circleRedStar" data-attr="svgTransform: translate(3, 3)"></div>
     <div class="anim-viewboxas slide" data-what=".svg1 svg, .svg2 svg" data-as="#zoomBox2"></div>
     <ul class="slide"><li>You can also make an object follow a path <br/>(forward and backard)</li></ul>
     <div class="slide anim-along" data-dur="2000" data-what=".svg1 #circleRedStar, .svg2 #circleRedStar, .svg3 #circleRedStar, .svg3 #circleGreen" data-path=".svg2 #yellowPath"></div>
     <div class="slide anim-along" data-dur="2000" data-what=".svg1 #circleRedStar, .svg3 #circleGreen" data-path=".svg2 #yellowPath" data-reverse="true"></div>
+    <div class="anim-attribute slide" data-what=".svg1 #circleRedStar" data-attr="svgTransform: translate(3, 3)"></div>
 </section>
 <!--section class="slide">
     <h2>Add/Remove Classes</h2>

Solution, that should be checked for side effects:

--- a/extensions/anim/deck.anim.js
+++ b/extensions/anim/deck.anim.js
@@ -169,7 +169,7 @@ https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
                             c.previousElement[i].attributes.getNamedItem(realAttrName).value = whatTo[k];
                         } else {
                            var realAttrName = svgRealAttrName(k) || k;
-                            c.previousElement[i].attributes.removeNamedItem(realAttrName);
+                            c.previousElement[i].attributes.getNamedItem(realAttrName).value = null;
                         }
                     } else {
                         $(c.previousElement[i]).animate(whatTo, 0);

(by H. Appel)