标签:
<script src="extras/jquery.min.1.7.js"></script> <div class="game" id="game" style="position: absolute;top: 0;left: 0"> <div>dsafsdf</div> </div> <script> isTouch = ‘ontouchstart‘ in window var mouseEvents = (isTouch) ? { down: ‘touchstart‘, move: ‘touchmove‘, up: ‘touchend‘, over: ‘touchstart‘, out: ‘touchend‘ } : { down: ‘mousedown‘, move: ‘mousemove‘, up: ‘mouseup‘, over: ‘mouseover‘, out: ‘mouseout‘ } var eventHandlers={ touchStart:function(){ } } var down=null document.getElementById("game").addEventListener(mouseEvents.down,function(e, opts, corner){ down=this console.log(this) },false) document.addEventListener(mouseEvents.move,function(e, opts, corner){ if(down){ e=e.changedTouches? e.changedTouches[0]:e $(down).css({"left":e.pageX,"top": e.pageY}) console.log(e) } },false) document.addEventListener(mouseEvents.up,function(e, opts, corner){ down=null },false) document.addEventListener(mouseEvents.over,function(e, opts, corner){ },false) // $(this).bind(mouseEvents.down, data.eventHandlers.touchStart). // bind(‘end‘, turnMethods._eventEnd). // bind(‘pressed‘, turnMethods._eventPressed). // bind(‘released‘, turnMethods._eventReleased). // bind(‘flip‘, turnMethods._flip); // // $(this).parent().bind(‘start‘, data.eventHandlers.start); // // $(document).bind(mouseEvents.move, data.eventHandlers.touchMove). // bind(mouseEvents.up, data.eventHandlers.touchEnd); </script>
标签:
原文地址:http://www.cnblogs.com/caoke/p/5007496.html