Skip to content

Commit

Permalink
Scroll lock now works correct with Page component
Browse files Browse the repository at this point in the history
  • Loading branch information
J.P.P Treub authored and J.P.P Treub committed Jul 21, 2015
1 parent 9e98ef0 commit 8972740
Show file tree
Hide file tree
Showing 34 changed files with 722 additions and 1 deletion.
5 changes: 4 additions & 1 deletion framer/Components/PageComponent.coffee
Expand Up @@ -153,10 +153,13 @@ class exports.PageComponent extends ScrollComponent
# See if we meet the minimum velocity to scroll to the next page. If not we snap # See if we meet the minimum velocity to scroll to the next page. If not we snap
# to the layer closest to the scroll point. # to the layer closest to the scroll point.


xDisabled = !@scrollHorizontal and (@direction == "right" or @direction == "left")
yDisabled = !@scrollVertical and (@direction == "down" or @direction == "up")

xLock = @content.draggable._directionLockEnabledX and (@direction == "right" or @direction == "left") xLock = @content.draggable._directionLockEnabledX and (@direction == "right" or @direction == "left")
yLock = @content.draggable._directionLockEnabledY and (@direction == "down" or @direction == "up") yLock = @content.draggable._directionLockEnabledY and (@direction == "down" or @direction == "up")


if Math.max(Math.abs(velocity.x), Math.abs(velocity.y)) < @velocityThreshold or xLock or yLock if Math.max(Math.abs(velocity.x), Math.abs(velocity.y)) < @velocityThreshold or xLock or yLock or xDisabled or yDisabled
# print "velocity" # print "velocity"
@snapToPage(@closestPage, true, @animationOptions) @snapToPage(@closestPage, true, @animationOptions)
return return
Expand Down
260 changes: 260 additions & 0 deletions framer/Components/PageComponent.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
@@ -0,0 +1,31 @@
horizontalPages = 3
verticalPages = 4

pageComp = new PageComponent
size: Screen.size
directionLock: true

verticalPCs = []

for horizontalPageIndex in [0...horizontalPages]
for verticalPageIndex in [0...verticalPages]
page = new Layer
x: horizontalPageIndex * Screen.width
y: verticalPageIndex * Screen.height
size: Screen.size
backgroundColor: "#28affa"
superLayer: pageComp.content
html: "#{horizontalPageIndex}:#{verticalPageIndex}"
style:
lineHeight: "#{Screen.height}px"
textAlign: "center"
fontSize: "240px"
fontWeight: "100"
fontFamily: "Helvetica Neue"

pageComp.on Events.Move, (scrollOffset) ->
if scrollOffset.y == 0
pageComp.scrollHorizontal = true
else
if pageComp.scrollHorizontal
pageComp.scrollHorizontal = false

Large diffs are not rendered by default.

@@ -0,0 +1,10 @@
{
"device" : "iPhone 5S Space Gray",
"sharedPrototype" : 1,
"deviceOrientation" : 0,
"contentScale" : 1,
"deviceType" : "fullscreen",
"updateDelay" : 0.3,
"deviceScale" : -1,
"delay" : 0.3
}

0 comments on commit 8972740

Please sign in to comment.