When I first started working on the front-end page, I also came into contact with js, but then I was attracted by the simple and efficient jquery and have been used to this day.
And js is abandoned by my subjective view of the underlying technology.
Until these days, I need to study the touch screen sliding events of mobile pages. It is really cumbersome to search for the corresponding technical support of jquery (of course, it may be that I do not have enough understanding of jquery), and js only needs a few steps to define it simply.
Since I know little about js, I have tried the simplest application for a long time... Let's share the actual reference to the touch event of js:
$(function(){document.addEventListener("touchmove", _touch, false);})function _touch(event){alert(1);}The above code inevitably uses certain things in jquery, and those who do not use jquery can be ignored.
The corresponding events are:
touchstart: Triggered when the finger touches the screen; triggers even if one finger is already placed on the screen.
touchmove: triggers continuously when the finger slides on the screen. During this event, calling preventDefault() prevents scrolling.
touchend: Triggered when the finger is removed from the screen.
touchcancel: Triggered when the system stops tracking touch. The exact trigger event for this event is not explicitly stated in the documentation.
The following attributes exist on the event objects of the above events:
touches: an array of touch objects representing the currently tracked touch operation.
targetTouches: an array of Touch objects specific to the event target.
changeTouches: an array of Touch objects that represent what has changed since the last touch.
Each Touch object contains the following properties:
clientX: Touch the X coordinate of the target in the viewport.
clientY: Touch the Y coordinate of the target in the viewport.
identifier: represents the unique ID of the touch.
pageX: Touch the x coordinate of the target in the page.
pageY: Touch the y-coordinate of the target in the page.
screenX: Touch the x coordinate of the target in the screen.
screenY: Touch the y-coordinate of the target in the screen.
target: Touched DOM node coordinates
Well, I've just started learning, so I'll write down some of the attributes from Baidu first.