Skip to content

Instantly share code, notes, and snippets.

@awt2542
Created November 12, 2017 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awt2542/5740be01da9e2f1435f35994f7cd1778 to your computer and use it in GitHub Desktop.
Save awt2542/5740be01da9e2f1435f35994f7cd1778 to your computer and use it in GitHub Desktop.
PageIndicator module
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