Skip to content

Commit

Permalink
Fix point conversion on Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Jul 19, 2016
1 parent 997b336 commit 7143e64
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 45 deletions.
3 changes: 3 additions & 0 deletions extras/Studio.framer/.gitignore
Expand Up @@ -37,3 +37,6 @@ app.js
framer/images/* framer/images/*
framer/framer*.js framer/framer*.js
framer/framer*.js.map framer/framer*.js.map

.preview.html
.viewer.html
46 changes: 3 additions & 43 deletions extras/Studio.framer/app.coffee
@@ -1,44 +1,4 @@
scroll = new ScrollComponent layer = new Layer
name: "MainScroll" size: Screen.size
height: Framer.Screen.height
width: Framer.Screen.width
scrollHorizontal: false
directionLock: true
backgroundColor: 'white'


rows = [] layer.onTap (e) -> print e.point

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}"

3 changes: 3 additions & 0 deletions framer/Context.coffee
Expand Up @@ -340,6 +340,9 @@ class exports.Context extends BaseClass
return unless @_element return unless @_element
@_element.style["z-index"] = value @_element.style["z-index"] = value


ancestors: (args...) ->
return @_parent?.ancestors(args...) or []

toInspect: -> toInspect: ->


round = (value) -> round = (value) ->
Expand Down
5 changes: 3 additions & 2 deletions framer/GestureInputRecognizer.coffee
Expand Up @@ -328,8 +328,9 @@ class exports.GestureInputRecognizer


_getGestureEvent: (event) -> _getGestureEvent: (event) ->


eventPoint = Utils.convertPoint( # Convert the point to the current context
@_getEventPoint(event), null, Framer.CurrentContext, true) eventPoint = Utils.convertPointFromContext(
@_getEventPoint(event), Framer.CurrentContext, true, false)


_.extend event, _.extend event,
time: Date.now() # Current time √ time: Date.now() # Current time √
Expand Down
2 changes: 2 additions & 0 deletions framer/Utils.coffee
Expand Up @@ -1002,8 +1002,10 @@ Utils.convertPointFromContext = (point = {}, layer, rootContext=false, includeLa
ancestors = layer.ancestors(rootContext) ancestors = layer.ancestors(rootContext)
ancestors.reverse() ancestors.reverse()
ancestors.push(layer) if includeLayer ancestors.push(layer) if includeLayer

for ancestor in ancestors for ancestor in ancestors
point = ancestor.matrix3d.inverse().point(point) point = ancestor.matrix3d.inverse().point(point)

return point return point


# convert a frame from the context level to a layer, with rootContext enabled you can make it start from the top context # convert a frame from the context level to a layer, with rootContext enabled you can make it start from the top context
Expand Down

0 comments on commit 7143e64

Please sign in to comment.