The vue mobile terminal determines the direction of finger sliding on the screen for your reference. The specific content is as follows This can be used to implement the function of switching tabs by sliding the screen with your finger. For example, on JD.com's order page, these tab switches can be implemented using this page <div @touchstart="handleTouchstart" @touchend="handleTouchend" class="slotWrap" > //Screen sliding//Finger pressing the screen handleTouchstart(event){ this.startTime = Date.now() this.startX = event.changedTouches[0].clientX this.startY = event.changedTouches[0].clientY }, //Finger leaves the screen handleTouchend(event){ const endTime = Date.now() const endX = event.changedTouches[0].clientX const endY = event.changedTouches[0].clientY //Judge the duration of pressing if(endTime - this.startTime >2000){ return } //Sliding direction let direction = ""; //First determine whether the user's sliding distance is legal. If legal: determine the sliding direction. Note that the distance must be added with the absolute value if (Math.abs (endX - this.startX) > 10) { //Sliding directionif(Math.abs(endY -this.startY)>30){ // console.log("The y direction is too offset, so you can't slide") return }else{ direction = endX -this.startX >0?"right":"left" } }else{ return } //The user has made a legal sliding operation // console.log('direction'+direction) if(direction==='left'){ if (this.currents+1 === this.list.length) { return }else{ this.currents++ //Trigger event this.$emit('getData') } } if(direction==='right'){ if (this.currents === 0) { return }else{ this.currents-- //Trigger event this.$emit('getData') } } } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: MariaDB under Linux starts with the root user (recommended)
>>: Ubuntu 18.04 installs pyenv, pyenv-virtualenv, virtualenv, Numpy, SciPy, Pillow, Matplotlib
Table of contents 1. Add attributes 2. Merge mult...
Anyone who has read my articles recently knows th...
Table of contents 1. Prepare materials 2. Downloa...
Copy code The code is as follows: <div style=&...
Preface When introducing defineProperty before, I...
1. Display the files or directories in the /etc d...
Table of contents 1. Basic Introduction to JavaSc...
Table of contents 1. Effect Demonstration 2. Impl...
Author: Guan Changlong is a DBA in the Delivery S...
Table of contents Introduction and Demo API: Cont...
This article example shares the specific code of ...
1. Record several methods of centering the box: 1...
webpack loads css files and its configuration Aft...
This article shares the specific code of node+exp...
Method 1: Download Pycharm and install Download a...