Skip to content
Permalink
Browse files

Fix an issue with nested ScrollComponents

  • Loading branch information...
koenbok committed Jul 15, 2016
1 parent 5714727 commit a303c80502938664e67cff9678fdc8a4cfd7b215
Showing with 63 additions and 62 deletions.
  1. +44 −53 extras/Studio.framer/app.coffee
  2. +5 −4 extras/Studio.framer/framer/config.json
  3. +14 −5 framer/Layer.coffee
@@ -1,53 +1,44 @@
if not Utils.isFramerStudio()
Framer.Extras.Preloader.enable()
Framer.Extras.Hints.enable()

layer = new Layer
size: Screen

layer.onTap (e) ->
print Screen
print e.point

point = Utils.convertPoint(e.point, null, Framer.CurrentContext, true)

new Layer
midX: point.x
midY: point.y












#
# nav = new NavComponent
#
# grid = new GridComponent
# width: Screen.width * 2
# height: Screen.height * 2
# rows: 10
# columns: 10
#
# nav.push(grid)
#
# grid.renderCell = (layer) ->
# layer.image = Utils.randomImage(layer) + "?date=#{Date.now()}"
#
# layer.onClick ->
#
# large = new Layer
# size: Utils.frameInset(nav, 80)
# image: @image
#
# large.onTap ->
# nav.back()
#
# nav.modal(large)
#
scroll = new ScrollComponent
name: "MainScroll"
height: Framer.Screen.height
width: Framer.Screen.width
scrollHorizontal: false
directionLock: true
backgroundColor: 'white'

rows = []

for i in [0...4]
row = new Layer
height: 400
width: 400
x: 25
y: 25 + 425 * i
parent: scroll.content
backgroundColor: 'white'
name: "row#{i}"
rows.push(row)

for row in rows
storyScroll = new ScrollComponent
name: "StoryScroll"
height: 400
width: Framer.Screen.width
x: 0
y: 0
parent: row
backgroundColor: 'white'
scrollVertical: false
directionLock: true
name: "units#{row.index}"

# Add story units
for i in [0..4]
unit = new Layer
width: 400
height: 400
parent: storyScroll.content
x: 425 * i
backgroundColor: Utils.randomColor()
name: "unit#{i}"

@@ -5,12 +5,13 @@
"deviceOrientation" : 0,
"sharedPrototype" : 1,
"contentScale" : 1,
"deviceType" : "fullscreen",
"deviceType" : "apple-iphone-6s-gold",
"selectedHand" : "",
"updateDelay" : 0.3,
"deviceScale" : 1,
"deviceScale" : "fit",
"foldedCodeRanges" : [
"{96, 2417}"

],
"orientation" : 0
"orientation" : 0,
"fullScreen" : false
}
@@ -1002,17 +1002,26 @@ class exports.Layer extends BaseClass

# If this layer has a parent draggable view and its position moved
# while dragging we automatically cancel click events. This is what
# you expect when you add a button to a scroll content layer.

if @_cancelClickEventInDragSession
if eventName in [Events.Click,
Events.Tap, Events.TapStart, Events.TapEnd,
# you expect when you add a button to a scroll content layer. We only
# want to do this if this layer is not draggable itself because that
# would break nested ScrollComponents.

if @_cancelClickEventInDragSession and not @_draggable

if eventName in [
Events.Click, Events.Tap, Events.TapStart, Events.TapEnd,
Events.LongPress, Events.LongPressStart, Events.LongPressEnd]

parentDraggableLayer = @_parentDraggableLayer()

if parentDraggableLayer

# If we had a reasonable scrolling offset we cancel the click
offset = parentDraggableLayer.draggable.offset
return if Math.abs(offset.x) > @_cancelClickEventInDragSessionOffset
return if Math.abs(offset.y) > @_cancelClickEventInDragSessionOffset

# If there is still some velocity (scroll is moving) we cancel the click
velocity = parentDraggableLayer.draggable.velocity
return if Math.abs(velocity.x) > @_cancelClickEventInDragSessionVelocity
return if Math.abs(velocity.y) > @_cancelClickEventInDragSessionVelocity

0 comments on commit a303c80

Please sign in to comment.
You can’t perform that action at this time.