From 6327512f1afe304891f5fb5e59afc15e55d70ba1 Mon Sep 17 00:00:00 2001 From: Rémi Tétreault Date: Sat, 25 Feb 2017 13:23:23 -0500 Subject: Add tests for the method atEnd of the FX module List of changes: * Add tests for atEnd for the case the animation is in a infinite loop * Fix a bug in atEnd that was uncovered by the new tests * Fix the indentation of the methods atStart and atEnd * Improve the comments of some of the others tests of atEnd --- src/fx.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/fx.js b/src/fx.js index 8e4fb0f..fd343e0 100644 --- a/src/fx.js +++ b/src/fx.js @@ -301,22 +301,24 @@ SVG.FX = SVG.invent({ // set the internal animation pointer at the start position, before any loops, and updates the visualisation , atStart: function() { - return this.at(0, true) - } + return this.at(0, true) + } // set the internal animation pointer at the end position, after all the loops, and updates the visualisation , atEnd: function() { - if (this.situation.loops === true) { - // If in a infinite loop, we end the current iteration - return this.at(this.situation.loop+1, true) - } else if(typeof this.situation.loops == 'number') { - // If performing a finite number of loops, we go after all the loops - return this.at(this.situation.loops, true) - } else { - // If no loops, we just go at the end - return this.at(1, true) + if (this.situation.loops === true) { + // If in a infinite loop, we end the current iteration + this.situation.loops = this.situation.loop + 1 + } + + if(typeof this.situation.loops == 'number') { + // If performing a finite number of loops, we go after all the loops + return this.at(this.situation.loops, true) + } else { + // If no loops, we just go at the end + return this.at(1, true) + } } - } // set the internal animation pointer to the specified position and updates the visualisation // if isAbsPos is true, pos is treated as an absolute position -- cgit v1.2.3