MCPcopy Create free account
hub / github.com/reactstrap/reactstrap / handleTouchEnd

Method handleTouchEnd

src/Carousel.js:142–166  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

140 }
141
142 handleTouchEnd(e) {
143 if (!this.props.enableTouch) {
144 return;
145 }
146
147 const currentX = e.changedTouches[0].screenX;
148 const currentY = e.changedTouches[0].screenY;
149 const diffX = Math.abs(this.touchStartX - currentX);
150 const diffY = Math.abs(this.touchStartY - currentY);
151
152 // Don't swipe if Y-movement is bigger than X-movement
153 if (diffX < diffY) {
154 return;
155 }
156
157 if (diffX < SWIPE_THRESHOLD) {
158 return;
159 }
160
161 if (currentX < this.touchStartX) {
162 this.props.next();
163 } else {
164 this.props.previous();
165 }
166 }
167
168 getContextValue() {
169 return { direction: this.state.direction };

Callers

nothing calls this directly

Calls 2

nextMethod · 0.80
previousMethod · 0.80

Tested by

no test coverage detected