javascript - How to do something everytime .animate repetition ends -
var track = ti.ui.createview({ width: 100, height: 30, backgroundcolor: '#e8e8e8', top: '30%' }); var progress = ti.ui.createview({ left: 0, width: 1, height: 30, backgroundcolor: '#00c36a' }); track.add(progress); ti.ui.currentwindow.add(track); ti.ui.currentwindow.addeventlistener('open', function () { progress.animate({ width: 100, duration: 10000, repeat: 6 });
i have made custom progress bar using 2 views , .animate function. how do implement functionality everytime repetition of progress.animate() completed
try this:
var repeat = 6; var rep = 0; var autoprogress = function() { createanimation(progress, function() { alert('complete nÂȘ-> ' + rep); rep++; if (rep < repeat) { autoprogress(); } }); }; /** * create animation view * @param ti.ui.view view * @param {function} callback */ var createanimation = function(view, callback) { callback = _.isfunction(callback) ? callback : function() { }; //create animate var animate = titanium.ui.createanimation({ width : 100, duration : 10000, }); /** * fired when animation complete. */ animate.addeventlistener('complete', function() { view.width = 0; callback(); }); view.animate(animate); }; ti.ui.currentwindow.addeventlistener('open', autoprogress);
Comments
Post a Comment