Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing is not working with touch devices #35

Open
devjabeer opened this issue Mar 19, 2021 · 1 comment
Open

Resizing is not working with touch devices #35

devjabeer opened this issue Mar 19, 2021 · 1 comment

Comments

@devjabeer
Copy link

I tried provided demo on touch devices and I could not be able to resize the panes using fingers/touch drag. Touch support or fix would be appreciated. Thanks

@joohong89
Copy link

joohong89 commented Nov 14, 2024

Ran into this issue recently Hope this would help anyone who is still using this.

Since touch events are not supported, the event listeners for touchstart, touchend and touchmove can be added to trigger the mousedown, mouseup and mousemove of vue-multipane directly.

Example of what could be done.

Add ref to multipane and multipane-resizer

<multipane layout="vertical" ref="multipane"> ...
<multipane-resizer ref="resizer"> ...

Add the "mapper" methods

    multipaneTouchMove (e) {
      const touch = e.touches[0]
      const mouseEvent = new MouseEvent('mousemove', {
        bubbles: true,
        cancelable: true,
        clientX: touch.clientX,
        clientY: touch.clientY,
        button: 0 
      })
      this.$refs.multipane.$el.dispatchEvent(mouseEvent)
    },
    multipaneTouchStart (e) {
      const touch = e.touches[0]
      this.$refs.multipane.onMouseDown({
        target: touch.target,
        pageX: touch.clientX,
        pageY: touch.clientY
      })
    },
    multipaneTouchEnd (e) {
      const mouseEvent = new MouseEvent('mouseup', {
        bubbles: true,
        cancelable: true,
        button: 0
      })
      this.$refs.multipane.$el.dispatchEvent(mouseEvent)
    },

Register touchstart, touchend and touchmove listeners

      this.$refs.resizer.$el.addEventListener('touchmove', this.multipaneTouchMove)
      this.$refs.resizer.$el.addEventListener('touchstart', this.multipaneTouchStart)
      this.$refs.resizer.$el.addEventListener('touchend', this.multipaneTouchEnd)

Note: remember to remove these listener when component is destroyed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants