Skip to content
Permalink
Browse files

Comma spacing

Signed-off-by: Niels van Hoorn <nvh@nvh.io>
  • Loading branch information
nvh committed Sep 15, 2016
1 parent aedf25d commit cd057d19762ae290c318706e9bea7131aaed9f4a
@@ -2,62 +2,62 @@ class FPS

constructor: ->
@start()

start: ->
@_start = Utils.getTime()
@_time = @_start
@_frames = []
Framer.Loop.on("update", @tick)

stop: ->
Framer.Loop.off("update", @tick)

tick: =>
now = Utils.getTime()
@_frames.push(now - @_time)
@_time = now

totalTime: ->
@_time - @_start

droppedFrames: ->
_.filter @_frames, (t) -> t > (1 / 60) * 1.1

droppedFrameRate: ->
Utils.round(@droppedFrames().length / @totalTime(), 1)

averageFPS: ->
Utils.round(@_frames.length / Utils.sum(@_frames), 1)

testLayers = (n, options={}, callback) ->

options = _.defaults options,
width: 500
height: 500
time: 1

Framer.CurrentContext.reset()

counter = 0

endGame = ->

counter++

if counter == n
fps.stop()
callback?(fps)

root = new Layer
width: options.width
height: options.height
backgroundColor: "rgba(0, 0, 0, .1)"
clip: true

root.center()

layers = for i in [0..n]

layer = new Layer
width: 100, height: 100,
x: Math.random() * options.width - (.5 * 100)
@@ -74,9 +74,9 @@ testLayers = (n, options={}, callback) ->
x: Math.random() * options.width
y: Math.random() * options.height
time: options.time

animation.on(Events.AnimationEnd, endGame)



start = 40
@@ -87,12 +87,12 @@ stats = []
next = ->

testLayers current, {}, (fps) ->

print "#{current} layers at #{fps.averageFPS()} fps"

stats.push([current, fps.averageFPS()])
current = current + start

if fps.averageFPS() > minFPS
next()
else
@@ -103,39 +103,37 @@ next()


drawChart = (stats) ->

canvasLayer = new Layer
width: 500
height: 300
backgroundColor: "white"

canvasLayer.center()
canvasLayer.html = """<canvas
width='#{canvasLayer.width - 20}px'
canvasLayer.html = """<canvas
width='#{canvasLayer.width - 20}px'
height='#{canvasLayer.height-20}px'>
</canvas>"""

canvasElement = canvasLayer.querySelectorAll("canvas")[0]

data =
labels: stats.map (i) -> i[0].toString()
datasets: [
{
fillColor: "rgba(220,220,220,0.2)"
strokeColor: "rgba(220,220,220,1)"
pointColor: "rgba(220,220,220,1)"
pointStrokeColor: "#fff"
pointHighlightFill: "#fff"
pointHighlightStroke: "rgba(220,220,220,1)"
data: stats.map (i) -> i[1]
}
]
labels: stats.map (i) -> i[0].toString()
datasets: [
{
fillColor: "rgba(220, 220, 220, 0.2)"
strokeColor: "rgba(220, 220, 220, 1)"
pointColor: "rgba(220, 220, 220, 1)"
pointStrokeColor: "#fff"
pointHighlightFill: "#fff"
pointHighlightStroke: "rgba(220, 220, 220, 1)"
data: stats.map (i) -> i[1]
}
]

options = {}


lineChart = new Chart(canvasElement.getContext("2d")).Line(data, options)

print Framer.Version


print Framer.Version
@@ -281,7 +281,7 @@ class exports.Animation extends BaseClass
@options.curveOptions.values = animatorClassName
@options.curveOptions.time ?= @options.time

# All this is to support curve: "spring(100,20,10)". In the future we'd like people
# All this is to support curve: "spring(100, 20, 10)". In the future we'd like people
# to start using curveOptions: {tension:100, friction:10} etc

if parsedCurve.args.length
@@ -312,7 +312,7 @@ class exports.Animation extends BaseClass
for k, v of properties
if @isAnimatable(v)
animatableProperties[k] = v
else if Color.isValidColorProperty(k,v)
else if Color.isValidColorProperty(k, v)
animatableProperties[k] = new Color(v)


@@ -22,7 +22,7 @@ class exports.Animator
finished: ->
throw Error "Not implemented"

values: (delta=1/60,limit=100)->
values: (delta=1/60, limit=100)->
values = []
for i in [0..limit]
values.push(@next(delta))
@@ -62,7 +62,7 @@ class UnitBezier
constructor: (p1x, p1y, p2x, p2y) ->

# pre-calculate the polynomial coefficients
# First and last control points are implied to be (0,0) and (1.0, 1.0)
# First and last control points are implied to be (0, 0) and (1.0, 1.0)
@cx = 3.0 * p1x
@bx = 3.0 * (p2x - p1x) - @cx
@ax = 1.0 - @cx - @bx
@@ -36,7 +36,7 @@ class exports.BaseClass extends EventEmitter
# Better readonly errors for debugging

# else
# descriptor.set = (value) ->
# descriptor.set = (value) ->
# throw Error("#{@constructor.name}.#{propertyName} is readonly")

# Define the property
@@ -57,7 +57,7 @@ class exports.BaseClass extends EventEmitter

# We assume we don't import if there is no setter, because we can't
descriptor.importable = descriptor.importable and descriptor.set
# We also assume we don't export if there is no setter, because
# We also assume we don't export if there is no setter, because
# it is likely a calculated property, and we can't set it.
descriptor.exportable = descriptor.exportable and descriptor.set

@@ -76,7 +76,7 @@ class exports.BaseClass extends EventEmitter
for depend in descriptor.depends
if depend not in @[DefinedPropertiesOrderKey]
@[DefinedPropertiesOrderKey].push(depend)

@[DefinedPropertiesOrderKey].push(propertyName)

@simpleProperty = (name, fallback, options={}) ->
@@ -89,9 +89,9 @@ class exports.BaseClass extends EventEmitter

# Allows to easily proxy properties from an instance object
# Object property is in the form of "object.property"

objectKey = keyPath.split(".")[0]

descriptor = _.extend options,
get: ->
return unless _.isObject(@[objectKey])
@@ -130,7 +130,7 @@ class exports.BaseClass extends EventEmitter

set: (value) ->
propertyList = @_propertyList()
for k,v of value
for k, v of value
# We only apply properties that we know and are marked to be
# importable.
@[k] = v if propertyList[k]?.importable
@@ -167,7 +167,7 @@ class exports.BaseClass extends EventEmitter
@_id = @constructor[CounterKey]

_applyDefaults: (options) ->

return unless @constructor[DefinedPropertiesOrderKey]
return unless options

@@ -194,13 +194,12 @@ class exports.BaseClass extends EventEmitter
# For each known property (registered with @define) that has a setter, fetch
# the value from the options object, unless the prop is not importable.
# When there's no user value, apply the default value:

return unless descriptor.set

value = optionValue if descriptor.importable
value = Utils.valueOrDefault(optionValue, @_getPropertyDefaultValue(key))

return if value in [null, undefined]

@[key] = value

@[key] = value
@@ -22,7 +22,7 @@ class NavComponentTransition
b: {x: @navComponent.width}

@animationOptions =
curve: "spring(300,35,0)"
curve: "spring(300, 35, 0)"

forward: (animate=true, callback) ->
options = _.extend(@animationOptions, {animate:animate})
@@ -38,7 +38,7 @@ class NavComponentTransition
@layerA?.visible = true
@statesA?.switch("b", options)
@statesB?.switch("b", options)

f = Utils.callAfterCount(2, callback)
@statesA?.once(Events.StateDidSwitch, f)
@statesB?.once(Events.StateDidSwitch, f)
@@ -75,11 +75,11 @@ class NavComponentBackgroundTransition
class NavComponentDialogTransition extends NavComponentBackgroundTransition

constructor: (@navComponent, @layerA, @layerB) ->

if @layerB
@statesB = new LayerStates(@layerB)
@statesB.add
a:
a:
point: Align.center
scale: 0.8
opacity: 0
@@ -90,7 +90,7 @@ class NavComponentDialogTransition extends NavComponentBackgroundTransition
@statesB.on Events.StateWillSwitch, (from, to) =>
if to is "b"
@statesB.animationOptions =
curve: "spring(800,28,0)"
curve: "spring(800, 28, 0)"
if to is "a"
@statesB.animationOptions =
curve: "ease-out"
@@ -113,17 +113,17 @@ class NavComponentDialogTransition extends NavComponentBackgroundTransition
class NavComponentModalTransition extends NavComponentBackgroundTransition

constructor: (@navComponent, @layerA, @layerB) ->

if @layerB
@statesB = new LayerStates(@layerB)
@statesB.add
a:
a:
x: Align.center
y: @navComponent.height
b:
y: Align.bottom
@statesB.animationOptions =
curve: "spring(300,35,0)"
curve: "spring(300, 35, 0)"

if @navComponent.background
@background = @navComponent.background
@@ -142,4 +142,4 @@ class NavComponentModalTransition extends NavComponentBackgroundTransition
_.extend exports,
default: NavComponentTransition
dialog: NavComponentDialogTransition
modal: NavComponentModalTransition
modal: NavComponentModalTransition
@@ -22,7 +22,7 @@ class exports.PageComponent extends ScrollComponent
@define "originX", @simpleProperty("originX", .5)
@define "originY", @simpleProperty("originY", .5)
@define "velocityThreshold", @simpleProperty("velocityThreshold", 0.1)
@define "animationOptions", @simpleProperty("animationOptions", {curve:"spring(500,50,0)"})
@define "animationOptions", @simpleProperty("animationOptions", {curve:"spring(500, 50, 0)"})

constructor: ->
super
@@ -263,7 +263,7 @@ class exports.ScrollComponent extends Layer
return 0 unless @content
return -@content.draggable.angle

scrollToPoint: (point, animate=true, animationOptions={curve:"spring(500,50,0)"}) ->
scrollToPoint: (point, animate=true, animationOptions={curve:"spring(500, 50, 0)"}) ->

# We never let you scroll to a point that does not make sense (out of bounds). If you still
# would like to do that, access the .content.y directly.
@@ -279,10 +279,10 @@ class exports.ScrollComponent extends Layer
else
@content.point = contentPoint

scrollToTop: (animate=true, animationOptions={curve:"spring(500,50,0)"}) ->
scrollToTop: (animate=true, animationOptions={curve:"spring(500, 50, 0)"}) ->
@scrollToPoint({x:0, y:0}, animate, animationOptions)

scrollToLayer: (contentLayer, originX=0, originY=0, animate=true, animationOptions={curve:"spring(500,50,0)"}) ->
scrollToLayer: (contentLayer, originX=0, originY=0, animate=true, animationOptions={curve:"spring(500, 50, 0)"}) ->

if contentLayer and contentLayer.parent isnt @content
throw Error("Can't scroll to this layer because it's not in the ScrollComponent. Add it to the content like layer.parent = scroll.content.")
@@ -298,7 +298,7 @@ class exports.ScrollComponent extends Layer

return contentLayer

scrollToClosestLayer: (originX=0, originY=0, animate=true, animationOptions={curve:"spring(500,50,0)"}) ->
scrollToClosestLayer: (originX=0, originY=0, animate=true, animationOptions={curve:"spring(500, 50, 0)"}) ->
closestLayer = @closestContentLayer(originX, originY, animate, animationOptions)
if closestLayer
@scrollToLayer(closestLayer, originX, originY)

0 comments on commit cd057d1

Please sign in to comment.
You can’t perform that action at this time.