/**
 * Created by rockyl on 2019-11-16.
 */

const key = 'state-' + vm.id;
global[key] = true;

engine.Tween.get(props.target)
	.set({rotation: 0})
	.to({rotation: 360}, props.duration, engine.Ease.quintIn)
	.call(function () {
		next('success', args);
		playLoop();
	});

function playLoop() {
	let goon = global[key];
	if (goon) {
		engine.Tween.get(props.target)
			.set({rotation: 0})
			.to({rotation: 360}, props.duration / 4)
			.call(function () {
				engine.globalEvent.dispatchEvent('loop-end');
				playLoop();
			})
	}
}
