ran npm run tdd & generated TDD
This commit is contained in:
14
test/onUserInputChange/onUserInputChange.js
Normal file
14
test/onUserInputChange/onUserInputChange.js
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = callback => {
|
||||
let type = 'mouse',
|
||||
lastTime = 0;
|
||||
const mousemoveHandler = () => {
|
||||
const now = performance.now();
|
||||
if (now - lastTime < 20)
|
||||
(type = 'mouse'), callback(type), document.removeEventListener('mousemove', mousemoveHandler);
|
||||
lastTime = now;
|
||||
};
|
||||
document.addEventListener('touchstart', () => {
|
||||
if (type === 'touch') return;
|
||||
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user