<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      代碼改變世界

      Why AlloyFinger is so much smaller than hammerjs?

      2016-11-15 10:35  【當耐特】  閱讀(1564)  評論(0)    收藏  舉報

      AlloyFinger is the mobile web gesture solution at present inside my company, major projects are in use.

      You can browse the source on GitHub:https://github.com/AlloyTeam/AlloyFinger

      Relative projects using AlloyFinger as shown below:

      If you want to crop image, view image, you will need gesture support. so the AlloyFinger library will meet your project's needs.

      You can see it that AlloyFinger is so much smaller than hammerjs. Why AlloyFinger is so much smaller than hammerjs? keep reading...

      Architecture Design

      In fact, classes in hammerjs are not yet listed, there are so many more. So Over-engineered leads to a huge size.
      The essence of namespace,module and class is that you can easy to find the code you want to find. abstract all the logic into the classes is not necessarily a good design.
      Local process implementation, the whole is the object may be a good design. such as the design of AlloyFinger.there are only two classes Vector2 and AlloyFinger. the touchstart, touchmove, touchend event handler method is able to trigger out of the related gesture events, simple and direct!

      Detail

      As we all know, the browser has exposed four events to the developer, touchmove touchend touchcancel touchstart, the callback function in these four events can get TouchEvent.

      TouchEvent.touches Read only
      A TouchList of all the Touch objects representing all current points of contact with the surface, regardless of target or changed status.
      TouchEvent.changedTouches Read only
      A TouchList of all the Touch objects representing individual points of contact whose states changed between the previous touch event and this one.

      TouchEvent can get the coordinates of each finger, so the programming is so generated.

      Tap

      Click event has 300 millisecond delay in the mobile web. the essence of tap is touchend. but to judge the coordinates of the finger of touchstart and touchend when the coordinates of the hand x, y direction shift to less than 30 pixels. less than 30 pixels will trigger tap.

      longTap

      Touchstart will open a 750ms's setTimeout. the touchmove, touchend or tow fingers touch the screen will clear the timeout within 750ms. More than 750ms without touchend or touchmove will trigger longTap.

      swipe

      Here need to pay attention, when the touchstart's hand coordinates and touchend coordinates x, Y direction shift to more than 30, to determine the swipe, less than 30 will judge tap. So the user is from top to bottom, or from bottom to top, or from left to right, from right to left slide? Can be based on the above three judgments, the specific code is as follows:

      _swipeDirection: function (x1, x2, y1, y2) {
              return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
      }
      

      pinch

      This gesture is very high frequency of use, such as image cropping when the zoom in or out of the picture, you need to pinch.

      As shown above, the distance between two points of the ratio of scale to pinch. This scale will be mounted on the event, let the user feedback to the scale attribute of DOM transform or other elements.
      you can use the transformjs to set the dom's css3 transform.

      rotate

      As shown above, you can calculate the angle between the two gesture state using the vector inner product. But how to find the direction of rotation here? So you need to use Cross Vector.
      Use the positive and negative results of cross to determine the direction of rotation.

      Cross essence is actually the area, you can look at the following derivation:

      Therefore, the physical engine often used cross to calculate the moment of inertia, torque is the force multiplied by the vertical distance, equivalent to the area

      The End

      Some of the main event trigger principle has been explained in the above, as well as multipointStart, doubleTap, singleTap, multipointEnd can look at the source code, less than 200 lines of code should be very easy to digest. not only the gesture events, touchStart touchMove touchEnd and touchCancel also can be listened to.
      You can browse the source on GitHub:https://github.com/AlloyTeam/AlloyFinger
      Any comments or suggestions are welcome to create issue:https://github.com/AlloyTeam/AlloyFinger/issues

      主站蜘蛛池模板: 韩国无码av片在线观看| 国产线播放免费人成视频播放| 亚洲中文字幕伊人久久无码| 国产不卡一区二区四区| 中文字幕 日韩 人妻 无码| 18禁免费无码无遮挡网站| 国产亚洲AV电影院之毛片| 国内少妇偷人精品视频| 久久精品国产99亚洲精品| 一区二区三区四区五区色| 国产成人精品性色av麻豆| 九九热在线视频免费播放| 国产农村老太xxxxhdxx| 国产成人精品一区二三区在线观看| 在线精品自拍亚洲第一区| 久久这里只精品国产2| 国产不卡精品视频男人的天堂| 亚洲sm另类一区二区三区| 亚洲欧美日韩久久一区二区| 在线观看免费网页欧美成| 丰满少妇特黄一区二区三区| 亚洲人妻精品中文字幕| 亚洲精品国产自在久久| 达孜县| 国产成人无码区免费内射一片色欲 | 欧美乱大交aaaa片if| 澳门永久av免费网站| 亚洲中文字幕在线二页| 55大东北熟女啪啪嗷嗷叫| 在线观看国产午夜福利片| 久热这里有精品免费视频| 麻豆国产传媒精品视频| 久久婷婷五月综合色欧美| 日韩无人区码卡1卡2卡| 色狠狠色噜噜AV一区| 遵化市| 高中女无套中出17p| 野外做受三级视频| 欧美激情一区二区三区在线| 亚洲国产免费图区在线视频| 国产稚嫩高中生呻吟激情在线视频|