Since this is a PC page, there will be scaling problems, so it is better to build a page to move the end of the test
Swipe to try (only touch events are bundled here, you can use chrome emulation, or use the mobile device directly)
Effect Code:
varSwipebase= New Swipebase(),Msg=Document.getElementById(' msg ');Document.AddEventListener(' Touchstart ', function (E) { varTouche=E.Touches[0];Swipebase.Start(Touche.PageX);E.Preventdefault();});Document.AddEventListener(' Touchmove ', function (E) { varTouche=E.Touches[0];Swipebase.Move(Touche.PageX);});Document.AddEventListener(' Touchend ', function (E) {Swipebase.End();});function Swipebase() { varPrevX,ToX; This.Start= function (X) {PrevX=X;ToX= 0; }; This.Move= function (X) {ToX=X-PrevX;PrevX=X; }; This.End= function () { varS=Ten;//Adjust sensitivity here if (ToX>S) {Msg.InnerHTML=' <b> right </b> swipe '+ToX; } Else if (ToX< -S) {Msg.InnerHTML=' <b> left </b> swipe '+ToX; } Else{Msg.InnerHTML=' <b> not happening </b> sliding '+ToX; } };}
Swipe gesture judgment