Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # create a scroll component
- scroll = new ScrollComponent
- size: Screen.size
- scrollHorizontal: false
- # create a layer to put in the scroll component
- myLayer = new Layer
- width: Screen.width
- # make sure its tall enough to be scrollable
- height: Screen.height*2
- parent: scroll.content
- backgroundColor: "#blue"
- # listen for the onScroll event to fire and create two
- # temporary variables "event" and "layer"
- scroll.onScroll (event, layer) ->
- # print the scrolling layer's y position
- print layer.y
- # if the y-postition of layer that's scrolling is smaller than -200
- # change the background color of myLayer to red
- if layer.y < -200
- myLayer.backgroundColor = "red"
- # otherwise set it to blue
- else
- myLayer.backgroundColor = "blue"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement