Make modal easier to close if there is only one image
This commit is contained in:
parent
e74482d84b
commit
274d384572
@ -63,6 +63,11 @@ const MediaModal = {
|
|||||||
},
|
},
|
||||||
type () {
|
type () {
|
||||||
return this.currentMedia ? this.getType(this.currentMedia) : null
|
return this.currentMedia ? this.getType(this.currentMedia) : null
|
||||||
|
},
|
||||||
|
swipeDisableClickThreshold () {
|
||||||
|
// If there is only one media, allow more mouse movements to close the modal
|
||||||
|
// because there is less chance that the user wants to switch to another image
|
||||||
|
return () => this.canNavigate ? 1 : 30
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
class="modal-image-container"
|
class="modal-image-container"
|
||||||
:direction="swipeDirection"
|
:direction="swipeDirection"
|
||||||
:threshold="swipeThreshold"
|
:threshold="swipeThreshold"
|
||||||
|
:disable-click-threshold="swipeDisableClickThreshold"
|
||||||
@preview-requested="handleSwipePreview"
|
@preview-requested="handleSwipePreview"
|
||||||
@swipe-finished="handleSwipeEnd"
|
@swipe-finished="handleSwipeEnd"
|
||||||
@swipeless-clicked="hide"
|
@swipeless-clicked="hide"
|
||||||
|
@ -5,6 +5,8 @@ import GestureService from '../../services/gesture_service/gesture_service'
|
|||||||
* direction: a vector that indicates the direction of the intended swipe
|
* direction: a vector that indicates the direction of the intended swipe
|
||||||
* threshold: the minimum distance in pixels the swipe has moved on `direction'
|
* threshold: the minimum distance in pixels the swipe has moved on `direction'
|
||||||
* for swipe-finished() to have a non-zero sign
|
* for swipe-finished() to have a non-zero sign
|
||||||
|
* disableClickThreshold: the minimum distance in pixels for the swipe to
|
||||||
|
* not trigger a click
|
||||||
* perpendicularTolerance: see gesture_service
|
* perpendicularTolerance: see gesture_service
|
||||||
*
|
*
|
||||||
* Events:
|
* Events:
|
||||||
@ -34,6 +36,10 @@ const SwipeClick = {
|
|||||||
type: Function,
|
type: Function,
|
||||||
default: () => 30
|
default: () => 30
|
||||||
},
|
},
|
||||||
|
disableClickThreshold: {
|
||||||
|
type: Function,
|
||||||
|
default: () => 1
|
||||||
|
},
|
||||||
perpendicularTolerance: {
|
perpendicularTolerance: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 1.0
|
default: 1.0
|
||||||
@ -72,6 +78,7 @@ const SwipeClick = {
|
|||||||
this.$gesture = new GestureService.SwipeAndClickGesture({
|
this.$gesture = new GestureService.SwipeAndClickGesture({
|
||||||
direction: this.direction,
|
direction: this.direction,
|
||||||
threshold: this.threshold,
|
threshold: this.threshold,
|
||||||
|
disableClickThreshold: this.disableClickThreshold,
|
||||||
perpendicularTolerance: this.perpendicularTolerance,
|
perpendicularTolerance: this.perpendicularTolerance,
|
||||||
swipePreviewCallback: this.preview,
|
swipePreviewCallback: this.preview,
|
||||||
swipeEndCallback: this.end,
|
swipeEndCallback: this.end,
|
||||||
|
Loading…
Reference in New Issue
Block a user