timeline: prevent swipe on scroller (fix #937)
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/953/head
parent
915ee8487d
commit
e3223f3a3f
|
@ -14,20 +14,36 @@ export default defineComponent({
|
||||||
name: 'SwipeRefresh',
|
name: 'SwipeRefresh',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
/** Callback to execute when the user swipes down */
|
||||||
refresh: {
|
refresh: {
|
||||||
type: Function as PropType<() => Promise<any>>,
|
type: Function as PropType<() => Promise<any>>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Whether to allow the swipe action */
|
||||||
allowSwipe: {
|
allowSwipe: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique identifier for the swipe action.
|
||||||
|
* If the state changes, the swipe action is reset.
|
||||||
|
*/
|
||||||
state: {
|
state: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: Math.random(),
|
default: Math.random(),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ancestor element of the touch action
|
||||||
|
* target must match this query selector to be
|
||||||
|
* eligible for the swipe action.
|
||||||
|
*/
|
||||||
|
match: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
@ -131,6 +147,11 @@ export default defineComponent({
|
||||||
touchstart(event: TouchEvent) {
|
touchstart(event: TouchEvent) {
|
||||||
if (!this.allowSwipe) return;
|
if (!this.allowSwipe) return;
|
||||||
const touch = event.touches[0];
|
const touch = event.touches[0];
|
||||||
|
|
||||||
|
// Check if top element matches selector
|
||||||
|
if (this.match && !(<HTMLElement>touch.target).closest(this.match)) return;
|
||||||
|
|
||||||
|
// Start swipe action
|
||||||
this.end = this.start = touch.clientY;
|
this.end = this.start = touch.clientY;
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.on = true;
|
this.on = true;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<SwipeRefresh
|
<SwipeRefresh
|
||||||
class="container no-user-select"
|
class="container no-user-select"
|
||||||
ref="container"
|
ref="container"
|
||||||
|
match=".recycler"
|
||||||
:refresh="softRefreshSync"
|
:refresh="softRefreshSync"
|
||||||
:allowSwipe="allowSwipe"
|
:allowSwipe="allowSwipe"
|
||||||
:state="state"
|
:state="state"
|
||||||
|
|
Loading…
Reference in New Issue