* Handler for the 'touchmove' event. * * @param {object} event
( event )
| 119 | * @param {object} event |
| 120 | */ |
| 121 | onTouchMove( event ) { |
| 122 | |
| 123 | if( this.isSwipePrevented( event.target ) ) return true; |
| 124 | |
| 125 | let config = this.Reveal.getConfig(); |
| 126 | |
| 127 | // Each touch should only trigger one action |
| 128 | if( !this.touchCaptured ) { |
| 129 | this.Reveal.onUserInput( event ); |
| 130 | |
| 131 | let currentX = event.touches[0].clientX; |
| 132 | let currentY = event.touches[0].clientY; |
| 133 | |
| 134 | // There was only one touch point, look for a swipe |
| 135 | if( event.touches.length === 1 && this.touchStartCount !== 2 ) { |
| 136 | |
| 137 | let availableRoutes = this.Reveal.availableRoutes({ includeFragments: true }); |
| 138 | |
| 139 | let deltaX = currentX - this.touchStartX, |
| 140 | deltaY = currentY - this.touchStartY; |
| 141 | |
| 142 | if( deltaX > SWIPE_THRESHOLD && Math.abs( deltaX ) > Math.abs( deltaY ) ) { |
| 143 | this.touchCaptured = true; |
| 144 | if( config.navigationMode === 'linear' ) { |
| 145 | if( config.rtl ) { |
| 146 | this.Reveal.next(); |
| 147 | } |
| 148 | else { |
| 149 | this.Reveal.prev(); |
| 150 | } |
| 151 | } |
| 152 | else { |
| 153 | this.Reveal.left(); |
| 154 | } |
| 155 | } |
| 156 | else if( deltaX < -SWIPE_THRESHOLD && Math.abs( deltaX ) > Math.abs( deltaY ) ) { |
| 157 | this.touchCaptured = true; |
| 158 | if( config.navigationMode === 'linear' ) { |
| 159 | if( config.rtl ) { |
| 160 | this.Reveal.prev(); |
| 161 | } |
| 162 | else { |
| 163 | this.Reveal.next(); |
| 164 | } |
| 165 | } |
| 166 | else { |
| 167 | this.Reveal.right(); |
| 168 | } |
| 169 | } |
| 170 | else if( deltaY > SWIPE_THRESHOLD && availableRoutes.up ) { |
| 171 | this.touchCaptured = true; |
| 172 | if( config.navigationMode === 'linear' ) { |
| 173 | this.Reveal.prev(); |
| 174 | } |
| 175 | else { |
| 176 | this.Reveal.up(); |
| 177 | } |
| 178 | } |
no test coverage detected