Permalink
Browse files

Fix directionLock issues on mobile

  • Loading branch information...
Koen Bok
Koen Bok committed Apr 2, 2015
1 parent 9da6ec3 commit 705a6d1ed55309b4b3bff8f76eb34af248f56fc1
Showing with 16 additions and 7 deletions.
  1. +9 −6 framer/LayerDraggable.coffee
  2. +7 −1 test/studio/PageComponentLockDirection.framer/app.coffee
@@ -370,11 +370,14 @@ class exports.LayerDraggable extends BaseClass
@_directionLockEnabledX = Math.abs(correctedDelta.y) > @directionLockThreshold.y
@_directionLockEnabledY = Math.abs(correctedDelta.x) > @directionLockThreshold.x
xSlightlyPreferred = Math.abs(correctedDelta.y) > @directionLockThreshold.y / 2
ySlightlyPreferred = Math.abs(correctedDelta.x) > @directionLockThreshold.x / 2
# TODO: This wasn't working as advertised. We shouls have a way to scroll diagonally
# if we were sort of moving into both directions equally.
# Allow locking in both directions at the same time
@_directionLockEnabledX = @_directionLockEnabledY = true if (xSlightlyPreferred and ySlightlyPreferred)
# xSlightlyPreferred = Math.abs(correctedDelta.y) > @directionLockThreshold.y / 2
# ySlightlyPreferred = Math.abs(correctedDelta.x) > @directionLockThreshold.x / 2
# # Allow locking in both directions at the same time
# @_directionLockEnabledX = @_directionLockEnabledY = true if (xSlightlyPreferred and ySlightlyPreferred)
if @_directionLockEnabledX or @_directionLockEnabledY
@emit Events.DirectionLockDidStart,
@@ -427,8 +430,8 @@ class exports.LayerDraggable extends BaseClass
_onSimulationStep: (axis, state) =>
return if axis is "x" and (@_directionLockEnabledX or @horizontal is false)
return if axis is "y" and (@_directionLockEnabledY or @vertical is false)
return if axis is "x" and @horizontal is false
return if axis is "y" and @vertical is false
# The simulation state has x as value, it can look confusing here
# as we're working with x and y.
@@ -8,7 +8,7 @@ page = new PageComponent
page.scrollVertical = false
page.directionLock = true
for index in [0..8]
for index in [0..2]
pageContent = new ScrollComponent
width: page.width
@@ -20,6 +20,9 @@ for index in [0..8]
pageContent.scrollHorizontal = false
pageContent.directionLock = true
page.on Events.DirectionLockDidStart, (direction) ->
print "pageContent.DirectionLockDidStart", direction
rows = 10
gutter = 2
height = 200
@@ -39,3 +42,6 @@ for index in [0..8]
"text-align": "center"
"line-height": "#{cellLayer.height}px"
page.on Events.DirectionLockDidStart, (direction) ->
print "page.DirectionLockDidStart", direction

0 comments on commit 705a6d1

Please sign in to comment.