Skip to content

Commit

Permalink
Round timecodes to 3 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuttu committed Feb 17, 2012
1 parent 696a6d9 commit 49063c6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions butter/src/core/trackevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
popcornOptions = options.popcornOptions || {
start: that.start,
end: that.end
},
round = function( number, numberOfDecimalPlaces ) {
return Math.round( number * ( Math.pow( 10, numberOfDecimalPlaces ) ) ) / Math.pow( 10, numberOfDecimalPlaces );
};

popcornOptions.start = round( popcornOptions.start, 3 );
popcornOptions.end = round( popcornOptions.end, 3 );

em.apply( "TrackEvent", this );

this.update = function( updateOptions ) {
Expand All @@ -26,6 +32,12 @@
popcornOptions[ prop ] = updateOptions[ prop ];
} //if
} //for
if ( popcornOptions.start ) {
popcornOptions.start = round( popcornOptions.start, 3 );
}
if ( popcornOptions.end ) {
popcornOptions.end = round( popcornOptions.end, 3 );
}
em.dispatch( "trackeventupdated", that );
}; //update

Expand Down

0 comments on commit 49063c6

Please sign in to comment.