收藏
回答

movable-view 组件 disable 机制问题

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug movable-view 微信iOS客户端 6.6.7.1321 2.1.0

我想实现图片的拖拽排序,效果是:初始时图片不可被拖动,长按图片后图片会变大一些,并且可拖动,松手后又不可拖动(就像发朋友圈)。


为达到该效果,我把 movable-view 的 disabled 属性初始化为 true,在 longpress 事件中,再赋值为 false


然后我发现在第一次 longpress 中设置 disabled 属性,并不能让 movable-view 可拖动,而是必须要先松手,再去尝试拖动,此时 movable-view 才可被拖动。


预期效果希望能够在 disabled 为 true 的 movable-view 组件中,使用 longpress 事件修改 disabled 时能够立即生效。


代码片段


js

Page({
    data: {
        width: 100,
        height: 100,
        disabled: true,
        top: 0,
        left: 0
    },
 
    long: function(e) {
        this.setData({
            width: 110,
            height: 110,
            disabled: false,
            top: -5,
            left: -5
        });
    },
    end: function(e) {
        this.setData({
            width: 100,
            height: 100,
            top: 0,
            left: 0
        });
    },
    onChange: function(e) {
    }
})


wxml

<movable-area style="height: 200px; width: 200px; background: darkgreen;">
    <movable-view
            style="height: {{height}}px; width: {{width}}px; background: white; top: {{top}}px; left: {{left}}px; transition: width .2s linear, height .2s linear, top .2s linear, left .2s linear;"
            x="50"
            y="50"
            direction="all"
            out-of-bounds="true"
            disabled="{{disabled}}"
            catch:longpress="long"
            catch:touchend="end"
            bindchange="onChange"
    ></movable-view>
</movable-area>


回答关注问题邀请回答
收藏

2 个回答

  • A Little
    A Little
    2018-11-29

    楼主这个问题解决了吗?我也遇到了同样的问题。。。

    2018-11-29
    有用
    回复 1
    • 西赛德李
      西赛德李
      2018-11-30

      我放弃这个功能了,好久没去用,不知道现在怎么样

      2018-11-30
      回复
  • 刘乐
    刘乐
    2018-06-20

    我 用了 下 disabled 属性 无论是 true 还是 false 都不能 动

    是我的 姿势 不对么

    求 正确 的 使用 姿势

    disabled=“false


    2018-06-20
    有用
    回复 3
    • 西赛德李
      西赛德李
      2018-06-20

      要加大括号,不然你是把字符串 "false" 赋值给 disabled,那肯定是不能动的

      disabled="{{false}}"
      2018-06-20
      回复
    • 刘乐
      刘乐
      2018-06-20回复西赛德李

      哦。。 我试试

      2018-06-20
      回复
    • 刘乐
      刘乐
      2018-06-20回复西赛德李

      哦。。 我试试

      disabled="{{item.move == 1 ? false : true}}"

      可以 的 我原来 把 是 字符串了

      disabled="{{item.move == 1 ? ‘false‘ : ‘true‘}}"

      谢啦

      2018-06-20
      回复
登录 后发表内容