shipshapecode / shepherd

Guide your users through a tour of your app
https://shepherdjs.dev
Other
13k stars 646 forks source link

Touch scroll not possible on highlighted area #1717

Open freakzlike opened 2 years ago

freakzlike commented 2 years ago

It is not possible to scroll with touch on the highlighted area or on the modal. However touch scroll on the grayed area and mouse scroll is possible.

Reproduce

This can be tested on shepherdjs.dev:

  1. Open shepherdjs.dev on small mobile device or with dev-tools
  2. Click through the first two steps till you reach the 02. Example section
  3. Try to touch scroll on the code snippet on the example (should not work)
  4. Try to touch scroll on the 01. How to include code snippet (should work)
  5. Try to scroll with mouse wheel (should work)

The default behavior of the touchmove event has been disabled here: https://github.com/shipshapecode/shepherd/blob/99d4f995f79d6bf99ea55c2bd0c62f309f2de968/src/js/components/shepherd-modal.svelte#L90-L92 https://github.com/shipshapecode/shepherd/blob/99d4f995f79d6bf99ea55c2bd0c62f309f2de968/src/js/components/shepherd-modal.svelte#L98-L107

Workaround

I'm currently using this workaround to avoid the call of preventDefault

const allowTouchmove = (event) => {
  event.stopPropagation()
}

const tour = new Shepherd.Tour({
  defaultStepOptions: {
    when: {
      show () {
        const target = this.getTarget()
        if (target) {
          target.addEventListener('touchmove', allowTouchmove)
        }
      },
      hide () {
        const target = this.getTarget()
        if (target) {
          target.removeEventListener('touchmove', allowTouchmove)
        }
      }
    }
  }
})

Suggestion

IMO the preventDefault of the touchmove event should be at least avoidable through the step configuration (something like allowTouchScroll: true). Also the behavior between mouse scroll, touch scroll on grayed area and touch scroll on highlighted area feels inconsistent and not understandable for a user.

MarianSWA commented 1 year ago

Thanks for the workaround, it works! Hopefully an official fix is coming like you suggested

Antmatveev commented 1 year ago

How about such a solution? This worked for me. document.body.addEventListener('touchmove', event => event.stopPropagation())

thianlopezz commented 1 year ago

It is not possible to scroll with touch on the highlighted area or on the modal. However touch scroll on the grayed area and mouse scroll is possible.

Reproduce

This can be tested on shepherdjs.dev:

  1. Open shepherdjs.dev on small mobile device or with dev-tools
  2. Click through the first two steps till you reach the 02. Example section
  3. Try to touch scroll on the code snippet on the example (should not work)
  4. Try to touch scroll on the 01. How to include code snippet (should work)
  5. Try to scroll with mouse wheel (should work)

The default behavior of the touchmove event has been disabled here:

https://github.com/shipshapecode/shepherd/blob/99d4f995f79d6bf99ea55c2bd0c62f309f2de968/src/js/components/shepherd-modal.svelte#L90-L92

https://github.com/shipshapecode/shepherd/blob/99d4f995f79d6bf99ea55c2bd0c62f309f2de968/src/js/components/shepherd-modal.svelte#L98-L107

Workaround

I'm currently using this workaround to avoid the call of preventDefault

const allowTouchmove = (event) => {
  event.stopPropagation()
}

const tour = new Shepherd.Tour({
  defaultStepOptions: {
    when: {
      show () {
        const target = this.getTarget()
        if (target) {
          target.addEventListener('touchmove', allowTouchmove)
        }
      },
      hide () {
        const target = this.getTarget()
        if (target) {
          target.removeEventListener('touchmove', allowTouchmove)
        }
      }
    }
  }
})

Suggestion

IMO the preventDefault of the touchmove event should be at least avoidable through the step configuration (something like allowTouchScroll: true). Also the behavior between mouse scroll, touch scroll on grayed area and touch scroll on highlighted area feels inconsistent and not understandable for a user.

This partially works but I am getting a bug, on a real device when the keyboard is showing up it gets hidden right after, and don't let me type anything.

chuckcarpenter commented 2 days ago

@RobbieTheWagner I think this works as intended now? Tried the steps to repro and seems like it's fine.