【发布时间】:2015-03-15 04:01:50
【问题描述】:
我正在使用 Draggable 和 GenericSync 以及著名和流星著名的视图包,但不理解(显然)
我想拖动带有约束的表面,并在达到预定限制时执行另一个操作。我正在学习,并且从我发现的示例中,我无法以我正在寻找的灵活性程度来完成这项工作。请帮忙!我敢肯定,只要一两行字就能让我重回正轨。
这是我的简化模板(包装在 HeaderFooterView 内的 RenderController 中):
<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>
还有一些咖啡脚本:
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
【问题讨论】:
-
@mogga 你想用famono 和coffeescript 得到答案吗?如果没有,I have answered a similar question using pure famo.us.
-
@talves 两者都同意,同时考虑著名观点 - 我有自己的解决方案,我会尽快发布
标签: meteor coffeescript famo.us famono