Travis build: 1782 [cron]
This commit is contained in:
21
test/recordAnimationFrames/recordAnimationFrames.js
Normal file
21
test/recordAnimationFrames/recordAnimationFrames.js
Normal file
@ -0,0 +1,21 @@
|
||||
const recordAnimationFrames = (callback, autoStart = true) => {
|
||||
let running = true,
|
||||
raf;
|
||||
const stop = () => {
|
||||
running = false;
|
||||
cancelAnimationFrame(raf);
|
||||
};
|
||||
const start = () => {
|
||||
running = true;
|
||||
run();
|
||||
};
|
||||
const run = () => {
|
||||
raf = requestAnimationFrame(() => {
|
||||
callback();
|
||||
if (running) run();
|
||||
});
|
||||
};
|
||||
if (autoStart) start();
|
||||
return { start, stop };
|
||||
};
|
||||
module.exports = recordAnimationFrames;
|
||||
13
test/recordAnimationFrames/recordAnimationFrames.test.js
Normal file
13
test/recordAnimationFrames/recordAnimationFrames.test.js
Normal file
@ -0,0 +1,13 @@
|
||||
const test = require('tape');
|
||||
const recordAnimationFrames = require('./recordAnimationFrames.js');
|
||||
|
||||
test('Testing recordAnimationFrames', (t) => {
|
||||
//For more information on all the methods supported by tape
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof recordAnimationFrames === 'function', 'recordAnimationFrames is a Function');
|
||||
//t.deepEqual(recordAnimationFrames(args..), 'Expected');
|
||||
//t.equal(recordAnimationFrames(args..), 'Expected');
|
||||
//t.false(recordAnimationFrames(args..), 'Expected');
|
||||
//t.throws(recordAnimationFrames(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user