From 7d367284ab68388b63389eeab9e799ae171baa39 Mon Sep 17 00:00:00 2001 From: maxwellito Date: Sun, 29 May 2016 22:36:25 +0100 Subject: [PATCH] Fix #106 Thanks to jimshell ;) --- dist/vivus.js | 17 +++++++++-------- dist/vivus.min.js | 2 +- src/vivus.js | 16 ++++++++-------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/dist/vivus.js b/dist/vivus.js index 2e8eb15..a6af451 100644 --- a/dist/vivus.js +++ b/dist/vivus.js @@ -317,8 +317,8 @@ function Vivus (element, options, callback) { /** * Timing functions - ************************************** - * + ************************************** + * * Default functions to help developers. * It always take a number as parameter (between 0 to 1) then * return a number (between 0 and 1) @@ -383,7 +383,7 @@ Vivus.prototype.setElement = function (element, options) { case window.HTMLObjectElement: // If we have to wait for it var onLoad, self; - + self = this; onLoad = function (e) { if (self.isReady) { @@ -565,7 +565,7 @@ Vivus.prototype.mapping = function () { break; case 'scenario-sync': - path = paths[i]; + path = pathObj.el; pAttrs = this.parseAttr(path); pathObj.startAt = timePoint + (parsePositiveInt(pAttrs['data-delay'], this.delayUnit) || 0); pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); @@ -574,7 +574,7 @@ Vivus.prototype.mapping = function () { break; case 'scenario': - path = paths[i]; + path = pathObj.el; pAttrs = this.parseAttr(path); pathObj.startAt = parsePositiveInt(pAttrs['data-start'], this.delayUnit) || 0; pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); @@ -661,7 +661,7 @@ Vivus.prototype.trace = function () { * ressources, too much DOM manupulation.. * but it's the only way to let the magic happen on IE. * By default, this fallback is only applied on IE. - * + * * @param {Number} index Path index */ Vivus.prototype.renderPath = function (index) { @@ -680,7 +680,7 @@ Vivus.prototype.renderPath = function (index) { * This this mainly due to the case of passing an * object tag in the constructor. It will wait * the end of the loading to initialise. - * + * */ Vivus.prototype.init = function () { // Set object variables @@ -769,7 +769,7 @@ Vivus.prototype.finish = function () { /** * Set the level of progress of the drawing. - * + * * @param {number} progress Level of progress to set */ Vivus.prototype.setFrameProgress = function (progress) { @@ -822,6 +822,7 @@ Vivus.prototype.stop = function () { * */ Vivus.prototype.destroy = function () { + this.stop(); var i, path; for (i = 0; i < this.map.length; i++) { path = this.map[i]; diff --git a/dist/vivus.min.js b/dist/vivus.min.js index 9806e4e..bdd7e15 100644 --- a/dist/vivus.min.js +++ b/dist/vivus.min.js @@ -4,4 +4,4 @@ * @link https://github.com/maxwellito/vivus * @license MIT */ -"use strict";!function(t,e){function r(r){if("undefined"==typeof r)throw new Error('Pathformer [constructor]: "element" parameter is required');if(r.constructor===String&&(r=e.getElementById(r),!r))throw new Error('Pathformer [constructor]: "element" parameter is not related to an existing ID');if(!(r.constructor instanceof t.SVGElement||/^svg$/i.test(r.nodeName)))throw new Error('Pathformer [constructor]: "element" parameter must be a string or a SVGelement');this.el=r,this.scan(r)}function n(t,e,r){this.isReady=!1,this.setElement(t,e),this.setOptions(e),this.setCallback(r),this.isReady&&this.init()}r.prototype.TYPES=["line","ellipse","circle","polygon","polyline","rect"],r.prototype.ATTR_WATCH=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],r.prototype.scan=function(t){for(var e,r,n,i,a=t.querySelectorAll(this.TYPES.join(",")),o=0;o=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")},n.prototype.setCallback=function(t){if(t&&t.constructor!==Function)throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||function(){}},n.prototype.mapping=function(){var e,r,n,i,a,s,h,u;for(u=s=h=0,r=this.el.querySelectorAll("path"),e=0;e1?r.length-1:1),e=0;e=this.frameLength?(this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy(),this.callback(this)):(this.trace(),this.handle=i(function(){t.drawer()}))},n.prototype.trace=function(){var t,e,r,n;for(n=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength,t=0;t=o+a*e&&s>=r},n.prototype.docElem=t.document.documentElement,n.prototype.getViewportH=function(){var e=this.docElem.clientHeight,r=t.innerHeight;return r>e?r:e},n.prototype.scrollY=function(){return t.pageYOffset||this.docElem.scrollTop},i=function(){return t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e){return t.setTimeout(e,1e3/60)}}(),a=function(){return t.cancelAnimationFrame||t.webkitCancelAnimationFrame||t.mozCancelAnimationFrame||t.oCancelAnimationFrame||t.msCancelAnimationFrame||function(e){return t.clearTimeout(e)}}(),o=function(t,e){var r=parseInt(t,10);return r>=0?r:e},"function"==typeof define&&define.amd?define([],function(){return n}):"object"==typeof exports?module.exports=n:t.Vivus=n}(window,document); \ No newline at end of file +"use strict";!function(t,e){function r(r){if("undefined"==typeof r)throw new Error('Pathformer [constructor]: "element" parameter is required');if(r.constructor===String&&(r=e.getElementById(r),!r))throw new Error('Pathformer [constructor]: "element" parameter is not related to an existing ID');if(!(r.constructor instanceof t.SVGElement||/^svg$/i.test(r.nodeName)))throw new Error('Pathformer [constructor]: "element" parameter must be a string or a SVGelement');this.el=r,this.scan(r)}function n(t,e,r){this.isReady=!1,this.setElement(t,e),this.setOptions(e),this.setCallback(r),this.isReady&&this.init()}r.prototype.TYPES=["line","ellipse","circle","polygon","polyline","rect"],r.prototype.ATTR_WATCH=["cx","cy","points","r","rx","ry","x","x1","x2","y","y1","y2"],r.prototype.scan=function(t){for(var e,r,n,i,a=t.querySelectorAll(this.TYPES.join(",")),o=0;o=this.duration)throw new Error("Vivus [constructor]: delay must be shorter than duration")},n.prototype.setCallback=function(t){if(t&&t.constructor!==Function)throw new Error('Vivus [constructor]: "callback" parameter must be a function');this.callback=t||function(){}},n.prototype.mapping=function(){var e,r,n,i,a,s,h,u;for(u=s=h=0,r=this.el.querySelectorAll("path"),e=0;e1?r.length-1:1),e=0;e=this.frameLength?(this.stop(),this.currentFrame=this.frameLength,this.trace(),this.selfDestroy&&this.destroy(),this.callback(this)):(this.trace(),this.handle=i(function(){t.drawer()}))},n.prototype.trace=function(){var t,e,r,n;for(n=this.animTimingFunction(this.currentFrame/this.frameLength)*this.frameLength,t=0;t=o+a*e&&s>=r},n.prototype.docElem=t.document.documentElement,n.prototype.getViewportH=function(){var e=this.docElem.clientHeight,r=t.innerHeight;return r>e?r:e},n.prototype.scrollY=function(){return t.pageYOffset||this.docElem.scrollTop},i=function(){return t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e){return t.setTimeout(e,1e3/60)}}(),a=function(){return t.cancelAnimationFrame||t.webkitCancelAnimationFrame||t.mozCancelAnimationFrame||t.oCancelAnimationFrame||t.msCancelAnimationFrame||function(e){return t.clearTimeout(e)}}(),o=function(t,e){var r=parseInt(t,10);return r>=0?r:e},"function"==typeof define&&define.amd?define([],function(){return n}):"object"==typeof exports?module.exports=n:t.Vivus=n}(window,document); \ No newline at end of file diff --git a/src/vivus.js b/src/vivus.js index e0d2590..46daf25 100755 --- a/src/vivus.js +++ b/src/vivus.js @@ -65,8 +65,8 @@ function Vivus (element, options, callback) { /** * Timing functions - ************************************** - * + ************************************** + * * Default functions to help developers. * It always take a number as parameter (between 0 to 1) then * return a number (between 0 and 1) @@ -131,7 +131,7 @@ Vivus.prototype.setElement = function (element, options) { case window.HTMLObjectElement: // If we have to wait for it var onLoad, self; - + self = this; onLoad = function (e) { if (self.isReady) { @@ -313,7 +313,7 @@ Vivus.prototype.mapping = function () { break; case 'scenario-sync': - path = paths[i]; + path = pathObj.el; pAttrs = this.parseAttr(path); pathObj.startAt = timePoint + (parsePositiveInt(pAttrs['data-delay'], this.delayUnit) || 0); pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); @@ -322,7 +322,7 @@ Vivus.prototype.mapping = function () { break; case 'scenario': - path = paths[i]; + path = pathObj.el; pAttrs = this.parseAttr(path); pathObj.startAt = parsePositiveInt(pAttrs['data-start'], this.delayUnit) || 0; pathObj.duration = parsePositiveInt(pAttrs['data-duration'], this.duration); @@ -409,7 +409,7 @@ Vivus.prototype.trace = function () { * ressources, too much DOM manupulation.. * but it's the only way to let the magic happen on IE. * By default, this fallback is only applied on IE. - * + * * @param {Number} index Path index */ Vivus.prototype.renderPath = function (index) { @@ -428,7 +428,7 @@ Vivus.prototype.renderPath = function (index) { * This this mainly due to the case of passing an * object tag in the constructor. It will wait * the end of the loading to initialise. - * + * */ Vivus.prototype.init = function () { // Set object variables @@ -517,7 +517,7 @@ Vivus.prototype.finish = function () { /** * Set the level of progress of the drawing. - * + * * @param {number} progress Level of progress to set */ Vivus.prototype.setFrameProgress = function (progress) {