From ae59de54bdda4afecae5b506e33b2c6225f1c824 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 23 Aug 2013 21:28:17 -0500 Subject: [PATCH] Updated buttons and added some event handlers --- js/framework/framework-buttons.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/framework/framework-buttons.js b/js/framework/framework-buttons.js index 87252705c4..5123154010 100644 --- a/js/framework/framework-buttons.js +++ b/js/framework/framework-buttons.js @@ -1,12 +1,18 @@ (function(window, document, framework) { framework.Button = function() {} + // Process an the touchstart event and if this is a button, + // add the .active class so Android will show depressed + // button states. framework.Button.prototype._onTouchStart = function(event) { console.log('Touch start!', event); if(event.target && event.target.classList.contains('button')) { event.target.classList.add('active'); } }; + + + // Remove any active state on touch end/cancel/etc. framework.Button.prototype._onTouchEnd = function(event) { console.log('Touch end!', event); if(event.target && event.target.classList.contains('button')) { @@ -16,5 +22,6 @@ document.addEventListener('touchstart', framework.Button.prototype._onTouchStart); document.addEventListener('touchend', framework.Button.prototype._onTouchEnd); + document.addEventListener('touchcancel', framework.Button.prototype._onTouchEnd); })(this, document, this.FM = this.FM || {});