Created
November 12, 2017 16:19
-
-
Save awt2542/5740be01da9e2f1435f35994f7cd1778 to your computer and use it in GitHub Desktop.
PageIndicator module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PageIndicator extends Layer | |
constructor: (options = {} )-> | |
_.defaults options, | |
width: 50 | |
height: 10 | |
backgroundColor: "" | |
borderRadius: "50%" | |
super options | |
for i in [0...@amount] | |
circle = new Layer | |
parent: @ | |
size: @height | |
borderRadius: @borderRadius | |
x: @width/@amount*i | |
circle.states.active = | |
backgroundColor: "white" | |
@define "amount", | |
get: -> @_amount | |
set: (value) -> @_amount = value | |
@define "index", | |
set: (value) -> | |
for indicator in @children | |
indicator.stateSwitch "default" | |
@children[value]?.stateSwitch "active" | |
indicator = new PageIndicator | |
amount: 3 | |
indicator.index = 0 | |
indicator.center() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment