From 2c1eb2efc99be26f2ae72e0aa6c5623d4aebf743 Mon Sep 17 00:00:00 2001 From: "@shaozilee" Date: Thu, 18 Aug 2016 11:14:47 +0800 Subject: [PATCH] add restore function for inverts destroy() --- lib/fastclick.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/fastclick.js b/lib/fastclick.js index 3af4f9d6..3a610d83 100644 --- a/lib/fastclick.js +++ b/lib/fastclick.js @@ -726,6 +726,27 @@ }; + /** + * Restore add all FastClick's event listeners. + * + * @returns {void} + */ + FastClick.prototype.restore = function() { + var layer = this.layer; + + if (deviceIsAndroid) { + layer.addEventListener('mouseover', this.onMouse, true); + layer.addEventListener('mousedown', this.onMouse, true); + layer.addEventListener('mouseup', this.onMouse, true); + } + + layer.addEventListener('click', this.onClick, true); + layer.addEventListener('touchstart', this.onTouchStart, false); + layer.addEventListener('touchmove', this.onTouchMove, false); + layer.addEventListener('touchend', this.onTouchEnd, false); + layer.addEventListener('touchcancel', this.onTouchCancel, false); + }; + /** * Check whether FastClick is needed. *