收藏
回答

小程序Android版本touchmove 事件侦听

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug bindtouchmove 工具 6.7.3 2.3.0

- 当前 Bug 的表现(可附上截图)

    在安卓端绑小程序定一个view 的touchmove 事件时,纵向触摸滑动每秒只有5次事件回调

    但是用网页端复现的时候表现正常


- 预期表现


- 复现路径


- 提供一个最简复现 Demo

小程序代码:

- index.wxml

<view class="layer" bindtouchmove="layerMove">   

    <text>{{touchMovesPerSecond}}</text>

</view>


- index.js

const app = getApp()


Page({

    data: {

        touchMovesPerSecond: 0

    },


    touchMovesArray: [],


    layerMove: function(event) {

        this.touchMovesArray.push(new Date())

        const now = new Date()


        this.touchMovesArray = this.touchMovesArray.filter(time => time > now - 1000)


        this.setData({

            touchMovesPerSecond: this.touchMovesArray.length

        })

    }

})


--------------------------------------------分界线------------------------------------------


Web 端代码:

<!DOCTYPE html>

<html>

<head>

    <title></title>

    <style type="text/css">

        body, html {    

            background-color: #4e4d4d;

            margin: 0px;

            padding: 0px;

            height: 100%;}


        #container {

            background-color: red;

            height: 100%;

        }

    </style>

</head>

<body>

    <div id="container">

        <p id="count"></p>

    </div>

    <script>

        const touchMovesArray = []

        const handleMove = function() {

            touchMovesArray: [],


            touchMovesArray.push(new Date())

            const now = new Date()

            touchMovesArray = touchMovesArray.filter(time => time > now - 1000)


            document.querySelector('#count').innerHTML = touchMovesArray.length

        }


        var el = document.querySelector('#container')

        el.addEventListener("touchmove", handleMove, false);

    </script>

</body>

</html>

最后一次编辑于  2018-10-03
回答关注问题邀请回答
收藏

6 个回答

  • 禾店科技
    禾店科技
    2021-04-28

    由于小程序的逻辑和视图引擎是异步分离的,无法做到流畅。需要修改实现方式,或者不采取需要拖动的解决方案。

    2021-04-28
    有用 1
    回复
  • 蓝调
    蓝调
    03-27

    给canvas设置 disable-scroll="true" 解决!

    03-27
    有用
    回复
  • kk
    kk
    2019-03-14

    同遇到

    2019-03-14
    有用
    回复
  • lxin.
    lxin.
    2018-12-27

    由于小程序的逻辑和视图引擎是异步分离的,无法做到流畅。需要修改实现方式,或者不采取需要拖动的解决方案。

    2018-12-27
    有用
    回复
  • 二伺三天
    二伺三天
    2018-10-08

    同问,我是下拉,安卓机卡的要死

    2018-10-08
    有用
    回复
  • Alex
    Alex
    2018-10-03

    +1 我们也有这个问题

    2018-10-03
    有用
    回复
登录 后发表内容