Migrate touchcancel event in Touch
authorwanmingx.lin <wanmingx.lin@intel.com>
Wed, 17 Jul 2013 08:03:02 +0000 (16:03 +0800)
committerwanmingx.lin <wanmingx.lin@intel.com>
Wed, 17 Jul 2013 08:03:02 +0000 (16:03 +0800)
Signed-off-by: wanmingx.lin <wanmingx.lin@intel.com>
tests/Touch/index.html
tests/Touch/js/main.js

index b494e02..b3a4f57 100755 (executable)
@@ -57,6 +57,7 @@ Authors:
               <div id="scrollTarget" style="left: 145px;top:300px;position: absolute;"><img id="imageScroll" src="img/scroll.png" height="80" width="80"></img></div>
             </div>
             <p class="ui-li-desc">* Drag this red button in above eare.</p>
+            <p id="errormessage"></p>
         </div>
         <div data-role="footer" data-position="fixed">
         </div>
index 3e4ec65..b737a8a 100755 (executable)
@@ -62,6 +62,8 @@ jQuery(document).ready(function() {
 
         //touchmove event
         document.getElementById("scrollTarget").addEventListener('touchmove',  function (event){
+            var image = $("#imageScroll")[0];
+            image.src = "img/btn_down.png";
             var changedTouches = event.changedTouches;
             if(changedTouches.item(0).clientX <= getLeft($("#scrollEare")[0])+40){
                 scrollTarget.style.left = getLeft($("#scrollEare")[0])+"px";
@@ -80,6 +82,19 @@ jQuery(document).ready(function() {
         }, false);
 
         //touchend event
+        document.getElementById("scrollTarget").addEventListener('touchcancel',  function (event){
+            var image = $("#imageScroll")[0];
+            image.src = "img/scroll.png";
+        }, false);
+
+        document.getElementById("scrollTarget").addEventListener('touchend',  function (event){
+            var image = $("#imageScroll")[0];
+            if(image.src.toString().indexOf("scroll.png") == -1){
+              $("#errormessage").html("touchcancel event can not be fired");
+            }
+        }, false);
+
+        //touchend event
         document.getElementById("tabletouch").addEventListener('touchend',  function (event){
             if(step1 && step2 && step3){
                 EnablePassButton();