|
289 | 289 | hDistance = null, |
290 | 290 | vDistance = null, |
291 | 291 | vSwipe = false, |
| 292 | + hSwipe = false, |
292 | 293 | hSwipMinDistance = 10, |
293 | 294 | vSwipMinDistance = 50, |
294 | 295 | startCoords = {}, |
|
322 | 323 | event.stopPropagation(); |
323 | 324 | endCoords = event.originalEvent.targetTouches[0]; |
324 | 325 |
|
325 | | - if ( plugin.settings.closeBySwipe ) { |
| 326 | + if ( !hSwipe && plugin.settings.closeBySwipe ) { |
326 | 327 | vDistance = endCoords.pageY - startCoords.pageY; |
327 | 328 | if ( Math.abs( vDistance ) >= vSwipMinDistance || vSwipe ) { |
328 | 329 | var opacity = 0.75 - Math.abs(vDistance) / slider.height(); |
|
335 | 336 | } |
336 | 337 |
|
337 | 338 | hDistance = endCoords.pageX - startCoords.pageX; |
338 | | - hDistancePercent = hDistance*100/winWidth; |
| 339 | + hDistancePercent = hDistance*100/winWidth; |
339 | 340 |
|
340 | | - if( hDistance >= hSwipMinDistance || hDistance <= -hSwipMinDistance) { |
| 341 | + if( !hSwipe && !vSwipe && Math.abs( hDistance ) >= hSwipMinDistance) { |
341 | 342 | $('#swipebox-slider').css({ |
342 | 343 | '-webkit-transition' : '', |
343 | 344 | '-moz-transition' : '', |
|
346 | 347 | '-ms-transition' : '', |
347 | 348 | 'transition' : '' |
348 | 349 | }); |
| 350 | + hSwipe = true; |
| 351 | + } |
| 352 | + |
| 353 | + if( hSwipe ) { |
| 354 | + $('#swipebox-slider').css({ |
| 355 | + '-webkit-transform' : 'translateX(' + (currentX + hDistancePercent) +'%)', |
| 356 | + '-moz-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
| 357 | + '-o-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
| 358 | + '-khtml-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
| 359 | + '-ms-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
| 360 | + 'transform' : 'translateX(' + (currentX + hDistancePercent) + '%)' |
| 361 | + }); |
349 | 362 | } |
350 | | - $('#swipebox-slider').css({ |
351 | | - '-webkit-transform' : 'translateX(' + (currentX + hDistancePercent) +'%)', |
352 | | - '-moz-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
353 | | - '-o-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
354 | | - '-khtml-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
355 | | - '-ms-transform' : 'translateX(' + (currentX + hDistancePercent) + '%)', |
356 | | - 'transform' : 'translateX(' + (currentX + hDistancePercent) + '%)' |
357 | | - }); |
358 | 363 |
|
359 | 364 |
|
360 | 365 | } ); |
|
386 | 391 | 'transform' : 'translateX(' + currentX + '%)' |
387 | 392 | }); |
388 | 393 |
|
389 | | - if ( plugin.settings.closeBySwipe ) { |
| 394 | + if ( vSwipe ) { |
390 | 395 | if ( slider.css( 'opacity' ) <= 0.5) { |
391 | 396 | var vOffset = vDistance > 0 ? slider.height() : - slider.height(); |
392 | 397 | slider.animate( { top: vOffset + 'px', 'opacity': 0 }, |
|
398 | 403 | slider.animate( { top: 0, 'opacity': 1 }, 300 ); |
399 | 404 | } |
400 | 405 |
|
401 | | - if ( vSwipe ) { |
402 | | - vSwipe = false; |
403 | | - return; |
404 | | - } |
405 | | - } |
406 | | - |
407 | | - |
408 | | - if ( hDistance >= hSwipMinDistance ) { |
| 406 | + vSwipe = false; |
| 407 | + return; |
| 408 | + } else if ( hDistance >= hSwipMinDistance ) { |
409 | 409 |
|
410 | 410 | // swipeLeft |
411 | 411 | $this.getPrev(); |
|
0 commit comments