Skip to content

Commit

Permalink
requestAnimationFrame addition to utils. (#1107)
Browse files Browse the repository at this point in the history
* requestAnimationFrame addition to utils.

* Update util.js

* Update util.js

* Update util.js

* Update util.js

* Update util.js
  • Loading branch information
agamemnus authored and katspaugh committed May 31, 2017
1 parent 7778308 commit 0552da8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
/* Common utilities */
WaveSurfer.util = {
requestAnimationFrame: (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback, element) { setTimeout(callback, 1000 / 60); }
),

frame: function (func) {
return function () {
var my = this, args = arguments;
WaveSurfer.util.requestAnimationFrame(function () {
func.apply(my, args);
});
};
},

extend: function (dest) {
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function (source) {
Expand Down

0 comments on commit 0552da8

Please sign in to comment.