var doc = require('doc-js');

module.exports = function(hoverClass, selector){
    var down = [],
        selector = selector || 'button, a',
        hoverClass = hoverClass || 'hover';

    function setClasses(){
        for(var i = 0; i < down.length; i++){
            doc(down[i]).addClass(hoverClass);
        }
    }

    doc(document).on('touchstart mousedown', selector, function(event){
        var target = doc(event.target).closest(selector);
        down.push(target);
        setTimeout(setClasses, 50);
    });

    function cancelHover(event){
        if(event.defaultPrevented){
            return;
        }
        while(down.length){
            doc(down.pop()).removeClass(hoverClass);
        }
    }

    doc(document).on('touchend touchmove touchcancel mouseup mousemove', cancelHover);
};
var doc = require('doc-js');

module.exports = function(hoverClass, selector){
    var down = [],
        selector = selector || 'button, a',
        hoverClass = hoverClass || 'hover';

    doc(document).on('touchstart mousedown', selector, function(event){
        var target = doc(event.target).closest(selector);
        doc(target).addClass(hoverClass);
        down.push(target);
    });
    doc(document).on('touchend touchcancel mouseup mousemove', function(event){
        while(down.length){
            doc(down.pop()).removeClass(hoverClass);
        }
    });
};
--- 
+++ 
@@ -5,14 +5,26 @@
         selector = selector || 'button, a',
         hoverClass = hoverClass || 'hover';
 
+    function setClasses(){
+        for(var i = 0; i < down.length; i++){
+            doc(down[i]).addClass(hoverClass);
+        }
+    }
+
     doc(document).on('touchstart mousedown', selector, function(event){
         var target = doc(event.target).closest(selector);
-        doc(target).addClass(hoverClass);
         down.push(target);
+        setTimeout(setClasses, 50);
     });
-    doc(document).on('touchend touchcancel mouseup mousemove', function(event){
+
+    function cancelHover(event){
+        if(event.defaultPrevented){
+            return;
+        }
         while(down.length){
             doc(down.pop()).removeClass(hoverClass);
         }
-    });
+    }
+
+    doc(document).on('touchend touchmove touchcancel mouseup mousemove', cancelHover);
 };
Allow hover to be canceled by a scroll
