I'm working through use of Draggable and GenericSync with famous and meteor famous-views package and not understanding (obviously)
I'd like to drag a surface with constraints and perform another action when predetermined limits are reached. I'm learning and from the examples I've found, I haven't been able to get this working with the degree of flexibility I'm looking for. Please help! I'm sure it's one or two lines to get me back on track.
Here's my simplified template (wrapped in a RenderController within a HeaderFooterView):
<template name="test4">
{{#View origin='[.5,.5]' align='[.5,.5]'}}
{{>Surface id="cube4" template="cubeFace4" class="grayDarker" size="[400,400]" properties="padding:20px" modifier="Draggable"}}
{{/View}}
</template>
<template name="cubeFace4">
<div style="width: 90%; height: 90%; margin: 5.5% auto;">
{{>svgFamoWrapped}}
</div>
</template>
and some coffeescript:
Template.test4.rendered = ->
@fview = FView.byId 'cube4'
@drag = @fview.modifier # modifier is 'Draggable'
@cube = @fview.surface
position = [0,0]
# cube.pipe drag
@drag.setOptions
xRange: [-500,500]
yRange: [-10,10]
projection: 'Famous.Draggable._direction.x'
@sync = new Famous.GenericSync ['mouse','touch'] #,
# direction: Famous.GenericSync.DIRECTION_X
@cube.pipe @drag
@drag.pipe @sync
@drag.on 'update', (data) ->
position[0] += data.delta[0]
position[1] += data.delta[1]
console.log data
@drag.setPosition position
@drag.on 'end', =>
drag.setPosition [0,0],
curve: 'outElastic'
duration: 400