 _ = require "underscore"
+{config} = require "./config"
 utils = require "./utils"
 css = require "./css"
 

	
	stop: =>
		
		console.log "Animation.stop #{@animationName}" if @debug
		
		@_canceled = true
		

		curve ?= ""
		curve = curve.toLowerCase()
		
		# If the shift key is pressed, we would like to play the animation slowly.
		factor = config.timeSpeedFactor
		
		precision = @precision * factor
		time = @time * factor
		
		if curve in ["linear"]
			return bezier.defaults.Linear @precision, time
		else if curve in ["ease"]
			return bezier.defaults.Ease @precision, time
		else if curve in ["ease-in"]
			return bezier.defaults.EaseIn @precision, time
		else if curve in ["ease-out"]
			return bezier.defaults.EaseOut @precision, time
		else if curve in ["ease-in-out"]
			return bezier.defaults.EaseInOut @precision, time
		else if curve[.."cubic-bezier".length-1] is "cubic-bezier"
			v = parseCurve curve, "cubic-bezier"
			return bezier.BezierCurve v[0], v[1], v[2], v[3], precision, time
		else if curve[.."spring".length-1] is "spring"
			v = parseCurve curve, "spring"
			return spring.SpringCurve v[0], v[1], v[2], precision
		else

			# The default curve is linear
			console.log "Animation.parseCurve: could not parse curve '#{curve}'"
			return bezier.defaults.Linear @precision, @time


exports.Animation = Animation
