TWorldIsNButThis
V2EX  ›  问与答

如果各个层级的组件都有拖拽的功能,如何防止它们之间互相影响?

  •  
  •   TWorldIsNButThis · Mar 17, 2022 · 1572 views
    This topic created in 1528 days ago, the information mentioned may be changed or developed.
    demo https://stackblitz.com/edit/vitejs-vite-cvb6u1?file=src/App.tsx

    我在一个 pull to refresh 组件里套了一个 swiper
    swiper 里每一页都是一个 droppable 的 list
    list 里面是 dragable 的 item
    每次拖拽 item 就会导致 swiper 和 pull to refresh 都触发
    试着在 dragable 的 item 上 on touch move e.stopPropagation 或者 preventDefault 都没效果
    怎么解决这个问题也毫无头绪
    2 replies    2022-03-18 12:17:32 +08:00
    dablwow
        1
    dablwow  
       Mar 18, 2022
    拖拽 item 没有触发 pull to refresh ,这个应该是正确行为吧
    TWorldIsNButThis
        2
    TWorldIsNButThis  
    OP
       Mar 18, 2022 via iPhone
    @dablwow 是 demo 里的吗
    我后来找了个控制下拉高度的属性 在 ondragstart 的时候设为 0 就可以避免下拉
    但是 swiper 的左右滑动靠在 ondragstart 的时候设置 allow touch move 为 false 就不行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2862 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 466ea39e · 38ms · UTC 04:40 · PVG 12:40 · LAX 21:40 · JFK 00:40
    ♥ Do have faith in what you're doing.