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

if (args && args.hasOwnProperty('index')) {
	const key = 'state-' + vm.id;
	let index = args.index;
	let per = 360 / props.divid;
	let ratio = per * props.ratio;
	let rotation = 360 * 3 - index * per + Math.random() * ratio + (per - ratio) / 2;
	delete global[key];
	engine.globalEvent.once('loop-end', function () {
		engine.Tween.get(props.target || target)
			.to({rotation}, props.duration, engine.Ease.quintOut)
			.call(function () {
				next('success', args);
			})
	});
} else {
	engine.Tween.removeTweens(props.target || target);
	next('success', args);
}
