From d0442c422030b1e12b7ed50bfc7d8f720e1ad0d9 Mon Sep 17 00:00:00 2001 From: Luis Leiva Date: Fri, 23 Aug 2019 11:18:43 +0300 Subject: [PATCH] Use the new trigger API --- dist/jquery.sketchable.animate.min.js | 2 +- dist/sketchable.animate.min.js | 2 +- src/jquery.sketchable.animate.js | 11 +++++------ src/sketchable.animate.js | 10 ++++------ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/dist/jquery.sketchable.animate.min.js b/dist/jquery.sketchable.animate.min.js index 7cfc964..ee8fe7c 100644 --- a/dist/jquery.sketchable.animate.min.js +++ b/dist/jquery.sketchable.animate.min.js @@ -1 +1 @@ -!function(a){function b(a){function b(b,c,d){var f=c[d],g=c[d+1];if(0===d||f.strokeId!==g.strokeId){if(b.data.firstPointSize){var i=d>0?g:f;b.beginFill(b.data.strokeStyle).fillCircle(i.x,i.y,b.data.firstPointSize).endFill()}d>0&&"function"==typeof h.animationstep&&h.animationstep(a,e),b.closePath().beginPath()}f.strokeId===g.strokeId&&b.line(f.x,f.y,g.x,g.y).stroke()}function d(a){return a instanceof Array?{x:a[0],y:a[1],time:a[2],strokeId:a[4]}:a}for(var e=a.data(c),f=e.sketch,g=e.strokes,h=e.options.events,i=e.options.graphics,j=[],k=0;k0?f:e;b.beginFill(b.data.strokeStyle).fillCircle(g.x,g.y,b.data.firstPointSize).endFill()}d>0&&a.sketchable("trigger","animationstep"),b.closePath().beginPath()}e.strokeId===f.strokeId&&b.line(e.x,e.y,f.x,f.y).stroke()}function d(a){return a instanceof Array?{x:a[0],y:a[1],time:a[2],strokeId:a[4]}:a}for(var e=a.data(c),f=e.sketch,g=e.strokes,h=(e.options.events,e.options.graphics),i=[],j=0;j0?g:f;b.beginFill(b.data.strokeStyle).fillCircle(i.x,i.y,b.data.firstPointSize).endFill()}d>0&&"function"==typeof h.animationstep&&h.animationstep(a,e),b.closePath().beginPath()}f.strokeId===g.strokeId&&b.line(f.x,f.y,g.x,g.y).stroke()}function d(a){return a instanceof Array?{x:a[0],y:a[1],time:a[2],strokeId:a[4]}:a}for(var e=dataBind(a.elem)[c],f=e.sketch,g=e.strokes,h=e.options.events,i=e.options.graphics,j=[],k=0;k0?f:e;b.beginFill(b.data.strokeStyle).fillCircle(g.x,g.y,b.data.firstPointSize).endFill()}d>0&&a.trigger("animationstep"),b.closePath().beginPath()}e.strokeId===f.strokeId&&b.line(e.x,e.y,f.x,f.y).stroke()}function d(a){return a instanceof Array?{x:a[0],y:a[1],time:a[2],strokeId:a[4]}:a}for(var e=dataBind(a.elem)[c],f=e.sketch,g=e.strokes,h=(e.options.events,e.options.graphics),i=[],j=0;j 0 && typeof events.animationstep === 'function') - events.animationstep($instance, data); + if (t > 0) $instance.sketchable('trigger', 'animationstep'); + // Flag stroke change. sketch.closePath().beginPath(); } diff --git a/src/sketchable.animate.js b/src/sketchable.animate.js index c65a0b1..3f1dea5 100644 --- a/src/sketchable.animate.js +++ b/src/sketchable.animate.js @@ -39,8 +39,7 @@ } } - if (typeof events.animationstart === 'function') - events.animationstart(instance, data); + instance.trigger('animationstart'); var raf; var frame = 0; @@ -59,8 +58,8 @@ // Advance local count and check if current animation should end. if (++frame === fmtStrokes.length - 1) { cancelAnimationFrame(raf); - if (typeof events.animationend === 'function') - events.animationend(instance, data); + + instance.trigger('animationend'); } })(); @@ -93,8 +92,7 @@ .endFill(); } // Trigger step event for subsequent strokes. - if (t > 0 && typeof events.animationstep === 'function') - events.animationstep(instance, data); + if (t > 0) instance.trigger('animationstep'); // Flag stroke change. sketch.closePath().beginPath(); }