Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create a little input field class
- class module.exports extends Layer
- constructor: (options={}) ->
- options.backgroundColor ?= "#FFF"
- options.width ?= 344
- options.height ?= 140
- options.x ?= 0
- options.y ?= 0
- options.borderRadius ?= 2
- options.shadowY ?= 2
- options.shadowBlur ?= 2
- options.shadowColor ?= "rgba(0,0,0,0.12)"
- # adding new variables to this class
- options.deviceRes ?= 1
- options.fontFamily ?= "Roboto"
- super options
- @changeForDevice()
- # Change the scaling factor for different devices
- # nexus 5 would be 3 and iphone would be 2
- @define "deviceRes",
- get: -> @_deviceRes
- set: (value) ->
- @_deviceRes = value
- @define "fontFamily",
- get: -> @_fontFamily
- set: (value) ->
- @_fontFamily = value
- # This gets run to change all the @1x measurements
- # passed in and converts them appropriate to the device
- changeForDevice: () ->
- # scale up all the values that should adapt to
- # to the change of device. This list could get
- # long.
- Layer::setWidth.call @, @width * @deviceRes
- Layer::setHeight.call @, @height * @deviceRes
- Layer::setBorderRadius.call @, @borderRadius * @deviceRes
- Layer::setShadowY.call @, @shadowY * @deviceRes
- Layer::setShadowBlur.call @, @shadowBlur * @deviceRes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement