UNPKG

redshift

Version:

A JavaScript UX framework. Handles animation, UI physics and user input tracking.

30 lines (23 loc) 615 B
"use strict"; var utils = require('../utils/utils.js'), maxElapsed = 33, Timer = function () { this.elapsed = 16.7; this.current = utils.currentTime(); this.update(); }; Timer.prototype = { update: function () { this.prev = this.current; this.current = utils.currentTime(); this.elapsed = Math.min(this.current - this.prev, maxElapsed); return this.current; }, getElapsed: function () { return this.elapsed; }, clock: function () { this.current = utils.currentTime(); } }; module.exports = Timer;