提交 dffd5196 编写于 作者: shutao-dc's avatar shutao-dc

调整scroll-view示例 增加scroll-x、scroll-y均为false的场景 可正常触发touchmove事件

上级 db8b0f2b
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
<text class="uni-text">{{item.label}}</text> <text class="uni-text">{{item.label}}</text>
</view> </view>
</scroll-view> </scroll-view>
<scroll-view v-else :scroll-x="false" :scroll-top="scrollTop" :scroll-left="scrollLeft" <scroll-view v-else :scroll-y="scrollY" :scroll-top="scrollTop" :scroll-left="scrollLeft"
:upper-threshold="upperThreshold" :lower-threshold="lowerThreshold" :scroll-into-view="scrollIntoView" :upper-threshold="upperThreshold" :lower-threshold="lowerThreshold" :scroll-into-view="scrollIntoView"
:enable-back-to-top="enableBackToTop" :scroll-with-animation="scrollWithAnimation" :enable-back-to-top="enableBackToTop" :scroll-with-animation="scrollWithAnimation"
:show-scrollbar="showScrollbar" :rebound="rebound" @scrolltoupper="scrolltoupper" :show-scrollbar="showScrollbar" :rebound="rebound" @scrolltoupper="scrolltoupper"
@touchmove="onTouchMove"
@scrolltolower="scrolltolower" @scroll="scroll" @scrollend="scrollend" ref="scrollViewY" id="scrollViewY"> @scrolltolower="scrolltolower" @scroll="scroll" @scrollend="scrollend" ref="scrollViewY" id="scrollViewY">
<view class="item" :id="item.id" v-for="(item,_) in items"> <view class="item" :id="item.id" v-for="(item,_) in items">
<text class="uni-text">{{item.label}}</text> <text class="uni-text">{{item.label}}</text>
...@@ -38,7 +39,11 @@ ...@@ -38,7 +39,11 @@
</view> </view>
<view class="uni-option"> <view class="uni-option">
<text>是否横向滚动</text> <text>是否横向滚动</text>
<switch :checked="scrollX" @change="changeDirection"></switch> <switch :checked="scrollX" @change="changeDirectionX"></switch>
</view>
<view class="uni-option">
<text>是否竖向滚动</text>
<switch :checked="scrollY" @change="changeDirectionY"></switch>
</view> </view>
<view class="uni-common-pb"></view> <view class="uni-common-pb"></view>
<view class="uni-slider"> <view class="uni-slider">
...@@ -86,7 +91,8 @@ ...@@ -86,7 +91,8 @@
data() { data() {
return { return {
items: [] as Item[], items: [] as Item[],
scrollX: false, scrollX: false,
scrollY: true,
rebound: false, rebound: false,
scrollTop: 0, scrollTop: 0,
scrollLeft: 0, scrollLeft: 0,
...@@ -115,10 +121,21 @@ ...@@ -115,10 +121,21 @@
handleChangeScrollTop(e : SliderChangeEvent) { handleChangeScrollTop(e : SliderChangeEvent) {
this.scrollTop = e.detail.value; this.scrollTop = e.detail.value;
}, },
changeDirection() { changeDirectionX() {
this.scrollX = !this.scrollX; this.scrollX = !this.scrollX;
if(this.scrollX) {
this.scrollY = false
}
this.scrollTop = 0; this.scrollTop = 0;
this.scrollLeft = 0; this.scrollLeft = 0;
},
changeDirectionY() {
this.scrollY = !this.scrollY;
if(this.scrollY) {
this.scrollX = false
}
this.scrollTop = 0;
this.scrollLeft = 0;
}, },
handleScrollIntoView() { handleScrollIntoView() {
if (this.scrollX) { if (this.scrollX) {
...@@ -160,6 +177,9 @@ ...@@ -160,6 +177,9 @@
scrollend() { scrollend() {
console.log("滚动停止"); console.log("滚动停止");
}, },
onTouchMove() {
console.log("TouchMove");
},
//自动化测试专用 //自动化测试专用
checkScrollHeight(): Boolean { checkScrollHeight(): Boolean {
var element = this.$refs["scrollViewY"] var element = this.$refs["scrollViewY"]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册