我有一个大的父图层,边上有几个子行。我想防止在垂直拖动父项时水平拖动行。我的猜测是在draggable = false
上TouchStart
,但没有运气。
cellHeight = 170
cellWidth = 640
rows = 3
container = new Layer
container.draggable = true
container.draggable.speedX = 0
container.width = cellWidth
container.height = cellHeight * rows
container.on Events.TouchMove, ->
myLayer.draggable = false
container.on Events.TouchEnd, ->
container.animate
properties:
y: 0
curve: "spring(500, 40, 20)"
for row in [0..rows-1]
myLayer = new Layer
x: 0
y: cellHeight*row
width: cellWidth
height: cellHeight
backgroundColor: "#FFF"
myLayer.superLayer = container
myLayer.style =
borderBottom: "1px solid black"
myLayer.draggable = true
myLayer.draggable.speedY = 0
myLayer.on Events.TouchStart, ->
container.draggable = false
myLayer.on Events.TouchEnd, (event, touchedLayer) ->
container.draggable = true
touchedLayer.animate
properties:
x: 0
curve: "spring(700, 40, 20)"
答案 0 :(得分:0)
我测试了你的脚本。 您是否试图阻止在拖动孩子的同时移动父母? 您可以在for循环中尝试此操作:
myLayer.on Events.DragMove, ->
container.draggable.enabled = false
myLayer.on Events.DragEnd, ->
container.draggable.enabled = true