Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js react change slide by touch event

const [touchStart, setTouchStart] = React.useState(0);
const [touchEnd, setTouchEnd] = React.useState(0);

function handleTouchStart(e) {
    setTouchStart(e.targetTouches[0].clientX);
}

function handleTouchMove(e) {
    setTouchEnd(e.targetTouches[0].clientX);
}

function handleTouchEnd() {
    if (touchStart - touchEnd > 150) {
        // do your stuff here for left swipe
        moveSliderRight();
    }

    if (touchStart - touchEnd < -150) {
        // do your stuff here for right swipe
        moveSliderLeft();
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: &quot;[&quot;value&quot;]&quot; to array js 
Javascript :: Your task is to take every letter and its index and form a string out of them. javascript 
Javascript :: cercle progress bar angular 
Javascript :: make price comma jquery 
Javascript :: &lt;xsl:apply-templates select node text subnodes all 
Javascript :: Filters in Algolia search 
Javascript :: Previously visited page with vanilla JavaScript 
Javascript :: Finding the longest word in a string 
Javascript :: simple method 
Javascript :: js to es6 convertor 
Javascript :: js decrypt online 
Javascript :: 9.4.1.2. Loop Condition&para; 
Javascript :: Function for masking the character 
Javascript :: route methods 
Javascript :: action creators in redux 
Javascript :: typeorm cache all queries 
Javascript :: on number copy pase formate in reactjs 
Javascript :: how to identify the li anchor tag text is empty in javascript 
Javascript :: eslint failed to load react 
Javascript :: Private Class Methods and Accessors in es12 
Javascript :: How to get element margin in React 
Javascript :: how to send Flutter Color as json || convert String to Color Flutter 
Javascript :: Write File to the Operating System with NodeJS 
Javascript :: find duplicate objects in array js 
Javascript :: set state giving previously update data 
Javascript :: jquery input valueadd 
Javascript :: create filepulse connector with json 
Javascript :: change frame rate javascript 
Javascript :: Unhandled Navigation Error: angular dist build 
Javascript :: javascript events reference 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =