 ScrollEnd -> DragEnd
 """
 
+Events.ScrollStart = "scrollstart"
+Events.Scroll = "scroll"
+Events.ScrollEnd = "scrollend"
 
 class exports.ScrollComponent extends Layer
 

		get: -> @_contentInset
		set: (@_contentInset) ->
			@_updateContent()

	scrollToPoint: (point, animate=true, animationOptions={curve:"spring(500,50,0)"}) ->
		
		point = @_pointInConstraints(point)

		if animate
			point.x = -point.x if point.x
			point.y = -point.y if point.y
			animationOptions.properties = point
			@content.animate(animationOptions)
		else
			@point = point

	scrollToLayer: (contentLayer, animate=true, animationOptions={curve:"spring(500,50,0)"}) ->
		
		if contentLayer.superLayer isnt @content
			throw Error("This layer is not in the scroll component")

		# TODO: For now we can only scroll to top left. We should make that better.
		@scrollToPoint(contentLayer.point, animate, animationOptions)

	_pointInConstraints: (point) ->


		@content.draggable.enabled = true
		@content.draggable.momentum = true
		
		eventMappers = {}
		eventMappers[Events.DragStart] = Events.ScrollStart
		eventMappers[Events.DragMove] = Events.Scroll
		eventMappers[Events.DragEnd] = Events.ScrollEnd

		_.each eventMappers, (v, k) =>
			 @content.draggable.on k, (event) => @emit(v, event)

		@content.on("change:subLayers", @_updateContent)
		@_updateContent()
		
		# @_enableNativeScrollCapture()

	_updateContent: =>

