mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
only add move listener for pointer type started with, touch or mouse
This commit is contained in:
@@ -19,11 +19,14 @@
|
||||
queueElements[keyId] = ele;
|
||||
|
||||
// in XX milliseconds, set the queued elements to active
|
||||
setTimeout(activateElements, 60);
|
||||
|
||||
// add listeners to clear all queued/active elements onMove
|
||||
document.body.addEventListener('mousemove', clear, false);
|
||||
document.body.addEventListener('touchmove', clear, false);
|
||||
if(e.type === 'touchstart') {
|
||||
document.body.addEventListener('touchmove', clear, false);
|
||||
setTimeout(activateElements, 85);
|
||||
} else {
|
||||
document.body.addEventListener('mousemove', clear, false);
|
||||
ionic.requestAnimationFrame(activateElements);
|
||||
}
|
||||
|
||||
keyId = (keyId > 19 ? 0 : keyId + 1);
|
||||
break;
|
||||
@@ -44,6 +47,15 @@
|
||||
queueElements = {};
|
||||
}
|
||||
|
||||
function deactivateElements() {
|
||||
for(var key in activeElements) {
|
||||
if(activeElements[key]) {
|
||||
activeElements[key].classList.remove('active');
|
||||
delete activeElements[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onEnd(e) {
|
||||
// clear out any active/queued elements after XX milliseconds
|
||||
setTimeout(clear, 200);
|
||||
@@ -54,14 +66,7 @@
|
||||
queueElements = {};
|
||||
|
||||
// in the next frame, remove the active class from all active elements
|
||||
ionic.requestAnimationFrame(function(){
|
||||
for(var key in activeElements) {
|
||||
if(activeElements[key]) {
|
||||
activeElements[key].classList.remove('active');
|
||||
delete activeElements[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
ionic.requestAnimationFrame(deactivateElements);
|
||||
|
||||
// remove onMove listeners that clear out active elements
|
||||
document.body.removeEventListener('mousemove', clear);
|
||||
|
||||
Reference in New Issue
Block a user