Skip to content

Commit

Permalink
fix issue #208
Browse files Browse the repository at this point in the history
  • Loading branch information
ustbhuangyi committed Sep 11, 2017
1 parent 04c3a30 commit 237cd8c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion example/components/full-page-slide/full-page-slide.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div v-if="items.length" class="full-page-slide-wrapper">
<slide ref="slide" :autoPlay="false" :loop="false" :allowVerticalScroll="false">
<slide ref="slide" :autoPlay="false" :loop="false">
<div v-for="(item, index) in items">
<div class="full-page-img-wrapper" :style="getStyle(index)">
<div v-if="index === items.length -1" class="button-wrapper" @click="handleClick()">
Expand Down
5 changes: 0 additions & 5 deletions example/components/slide/slide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
click: {
type: Boolean,
default: true
},
allowVerticalScroll: {
ype: Boolean,
default: true
}
},
data() {
Expand Down Expand Up @@ -134,7 +130,6 @@
_initSlide() {
this.slide = new BScroll(this.$refs.slide, {
scrollX: true,
eventPassthrough: this.allowVerticalScroll ? 'vertical' : false,
momentum: false,
snap: {
loop: this.loop,
Expand Down
4 changes: 3 additions & 1 deletion src/scroll/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ const DEFAULT_OPTIONS = {
* for slide
* snap: {
* loop: false,
* el: domEl,
* threshold: 0.1,
* stepX: 100,
* stepY: 100
* stepY: 100,
* listenFlick: true
* }
*/
snap: false,
Expand Down
28 changes: 15 additions & 13 deletions src/scroll/snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,21 @@ export function snapMixin(BScroll) {
}
})

this.on('flick', () => {
let time = snap.speed || Math.max(
Math.max(
Math.min(Math.abs(this.x - this.startX), 1000),
Math.min(Math.abs(this.y - this.startY), 1000)
), 300)

this.goToPage(
this.currentPage.pageX + this.directionX,
this.currentPage.pageY + this.directionY,
time
)
})
if (snap.listenFlick !== false) {
this.on('flick', () => {
let time = snap.speed || Math.max(
Math.max(
Math.min(Math.abs(this.x - this.startX), 1000),
Math.min(Math.abs(this.y - this.startY), 1000)
), 300)

this.goToPage(
this.currentPage.pageX + this.directionX,
this.currentPage.pageY + this.directionY,
time
)
})
}
}

BScroll.prototype._nearestSnap = function (x, y) {
Expand Down

0 comments on commit 237cd8c

Please sign in to comment.