亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

快應用tabs和video組件滑動事件優先級問題

標簽:
Android

快应用tabs和video组件滑动事件优先级问题

现象描述:

tabs子组件tab-content内容是video组件组成的,左右滑动切换tabs内容时,偶尔会不切换而是拖动视频进度条。

问题代码如下:

<template>
  <div style="background-color: #00bfff;">
    <tabs index="0" >
      <tab-bar mode="fixed">
      </tab-bar>
      <tab-content>
        <div  style="flex-direction: column;">
          <text style="color: red">1</text>
          <stack class="video" >
            <video class="video1" id="111" 
              src="https://ss0.bdstatic.com/-0U0bnSm1A5BphGlnYG/cae-legoup-video-target/93be3d88-9fc2-4fbd-bd14-833bca731ca7.mp4">
              </video>
          </stack>
        </div>
 
        <div  style="flex-direction: column;">
          <text style="color: red">2</text>
        </div>
 
        <div style="flex-direction: column;">
          <text style="color: red">3</text>
        </div>
      </tab-content>
    </tabs>
  </div>
</template>

问题分析:

video组件是tabs的子组件,video组件和tabs组件都是自带滑动能力,此问题关键在于滑动的地方在video区域上,根据事件从里层往外层的冒泡机制,系统会优先处理video的滑动,而不是tabs的切换,而video的滑动效果就是我们看到的调整了视频播放进度。

解决方案:

在video区域上覆盖一层div(video父节点stack增加子节点div),注意div的高低要小于video的高度,保证video底部的进度条、播放按钮区域不被遮挡。当在video区域滑动时,实际上是在div上,由于div和video是兄弟节点,不会触发video的滑动事件,完美解决了以上问题。

实现代码如下(见红色部分):

<template>
  <div style="background-color: #00bfff;">
    <tabs index="0" >
      <tab-bar mode="fixed">
      </tab-bar>
      <tab-content>
        <div  style="flex-direction: column;">
          <text style="color: red">1</text>
          <stack class="video">
            <video class="video1" id="111" 
              src="https://ss0.bdstatic.com/-0U0bnSm1A5BphGlnYG/cae-legoup-video-target/93be3d88-9fc2-4fbd-bd14-833bca731ca7.mp4"
              onstart="start" ontouchmove="move" onseeked="seeked">
              </video>
              <div style="width: 100%;height:300px;" onclick="bof">
               </div>
          </stack>
        </div>
 
        <div  style="flex-direction: column;">
          <text style="color: red">2</text>
        </div>
 
        <div style="flex-direction: column;">
          <text style="color: red">3</text>
        </div>
 
      </tab-content>
    </tabs>
  </div>
</template>

原作者:Mayism

點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消