Created
October 30, 2012 18:32
-
-
Save lbj96347/3982102 to your computer and use it in GitHub Desktop.
Touch Effect Proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <!-- This is a template for Web App Setup --> | |
| <!-- Author : @CashLee李秉骏 --> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> | |
| <meta name="apple-mobile-web-app-capable" content="yes"> | |
| <meta name='description' content='' > | |
| <meta name='author' content='' > | |
| <title>hello world</title> | |
| <link rel='stylesheet' type='text/css' href='test.css' /> | |
| <script src="lib/zepto.js"></script> | |
| </head> | |
| <body> | |
| <div class="page_setup"> | |
| <button id="button_1">button 1</button> | |
| <button id="button_2">button 2</button> | |
| <div id="new_area" style="width:100%;height:200px;background:red;"></div> | |
| <div id="new_text"></div> | |
| </div> | |
| <p>备注:在上一个项目的制作过程中,需要在Web View中模拟Native的触摸反馈效果,但是对于触摸反馈,目前似乎仍然没有一个很好的管理类库,因此我在试图创建一个小型的库,专门用于处理触摸反馈事件。目前是基于jQuery语法写的(你可以搭配jQuery,jqmobi或者zepto.js 来使用。当然现在还是很简陋的,因为是从项目中随便抽出来的代码)。有好的建议,可以直接改我代码哦。</p> | |
| </body> | |
| <!-- script type='text/javascript' language='javascript' src="jquery-1.8.2.min.js"></script --> | |
| <script> | |
| $("#button_1").bind("click", function (){ | |
| $("#new_area").append("<button id=button_3 >button 3 !</button>"); | |
| }); | |
| var touchObject = function ( touchObjectName , touchStartEvent , touchMoveEvent , touchEndEvent ){ | |
| this.touchEventObject = [ "touchstart","touchmove","touchend"]; | |
| this.touchBindAction = function (){ | |
| $(touchObjectName).on( this.touchEventObject[0] , function (){ | |
| touchStartEvent(); | |
| }).on( this.touchEventObject[1] , function (){ | |
| touchMoveEvent(); | |
| }).on( this.touchEventObject[2] , function (){ | |
| touchEndEvent(); | |
| }); | |
| }; | |
| this.touchBindAction(); | |
| } | |
| var button3_touch_test = new touchObject( | |
| "#new_area", | |
| function (){ console.log(button3_touch_test.touchStyle) }, | |
| function (){ button3_touch_test.touchStyle }, | |
| function (){ button3_touch_test.touchStyle } | |
| ); | |
| </script> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment