Skip to content
Permalink
Browse files

Round non matrix values for animation

  • Loading branch information...
Koen Bok
Koen Bok committed Apr 20, 2013
1 parent c0207c0 commit 4e8f467966261b5bf92bb56b705ff5be467235c6
Showing with 9 additions and 7 deletions.
  1. +1 −1 src/animation.coffee
  2. +2 −3 src/primitives/matrix.coffee
  3. +6 −3 src/utils.coffee
@@ -281,7 +281,7 @@ class Animation extends EventEmitter
for propertyName, unit of @AnimatableCSSProperties
continue if not @propertiesA.hasOwnProperty propertyName
value = springValue * deltas[propertyName] + @propertiesA[propertyName]
cssString.push "#{propertyName}:#{value}#{unit}; "
cssString.push "#{propertyName}:#{ utils.round value, 5}#{unit}; "

cssString.push "}\n"

@@ -1,6 +1,5 @@
_ = require "underscore"

RoundValue = 1000
utils = require "../utils"

WebKitCSSMatrix::cssValues = ->

@@ -10,7 +9,7 @@ WebKitCSSMatrix::cssValues = ->
# noted numbers with e and css really does not like that.

# r = (v) -> v.toFixed 5
r = (v) -> Math.round(v * RoundValue) / RoundValue
r = (v) -> utils.round v, 5

values = "matrix3d(
#{r @m11}, #{r @m12}, #{r @m13}, #{r @m14},
@@ -56,7 +56,7 @@ exports.copy = (source) ->
# Public: Looks through properties of a source object, returning an Object
# of properties that path the iterator's truth test.
#
# NOTE: Although similarly named, utils.filter is not an ES5 compatible
# NOTE: Although similarly named, exports.filter is not an ES5 compatible
# filter implementation.
#
# source - an object that will be filtered
@@ -101,7 +101,7 @@ exports.remove = (a, e) ->
#
# Examples
#
# opacityToggle = utils.toggle(0, 1)
# opacityToggle = exports.toggle(0, 1)
# dropdown.on 'click', -> dropdown.opacity = opacityToggle()
#
# Returns a Function
@@ -291,6 +291,10 @@ exports.uuid = ->

output.join('')

exports.round = (value, decimals) ->
d = Math.pow 10, decimals
Math.round(value * d) / d


# Public: Returns a Boolean indicating wether the current browser uses the
# Webkit engine.
@@ -314,4 +318,3 @@ exports.isMobile = ->
navigator.userAgent.toLowerCase()



0 comments on commit 4e8f467

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