Travis build: 655

This commit is contained in:
Travis CI
2017-12-30 11:09:01 +00:00
parent 4d9d8e5c32
commit b25686b93e
3 changed files with 63 additions and 5 deletions

View File

@ -8,16 +8,17 @@ Run the callback with the input type as an argument in either of these situation
```js
const onUserInputChange = callback => {
let type = 'mouse', lastTime = 0;
let type = 'mouse',
lastTime = 0;
const mousemoveHandler = () => {
const now = performance.now();
if (now - lastTime < 20)
type = 'mouse', callback(type), document.removeEventListener('mousemove', mousemoveHandler);
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);
(type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler);
});
};
```