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

unable to scroll on touch screen devices when the dndzone fills the page #613

Open
NotLatif opened this issue Nov 12, 2024 · 5 comments
Open

Comments

@NotLatif
Copy link

Hi,

Touch input users are unable to scroll page when a dndzone fills it.

eg: https://www.youtube.com/shorts/mDiEBc7fLw0

Maybe an input delay would be a good workaround (you hold the item for x seconds before the drag action starts)

I tried doing it myself wrapping my dndzone in a <TouchDelayWrapper /> component made like this

<script>
    let touchTimeout;
    export let isDraggable = false;
    
    function handleTouchStart() {
      touchTimeout = setTimeout(() => {
        isDraggable = true;
        console.log('Touch hold');
      }, 500);
    }
  
    function handleTouchEnd() {
      clearTimeout(touchTimeout);
      isDraggable = false;
    }
  </script>
  
  <div 
    on:touchstart={handleTouchStart}
    on:touchend={handleTouchEnd}
    on:touchcancel={handleTouchEnd}
    style="touch-action: {isDraggable ? 'none' : 'pan-y pinch-zoom'}"
  >
    <slot {isDraggable}></slot>
  </div>

but I could not seem to find a way to update my dndzone reactively

<script>
  //...bla bla bla
  let parentDraggable = false;
</script>

<TouchDelayWrapper bind:isDraggable={parentDraggable}>

  <!-- this updates reactively -->
  <h1>{parentDraggable}</h1> 

  <!-- this does not -->
  <div use:dndzone={{items, flipDuration, dragDisabled: !parentDraggable}}>
      
  </div>
</TouchDelayWrapper>
@isaacHagoel
Copy link
Owner

isaacHagoel commented Nov 12, 2024 via email

@NotLatif
Copy link
Author

thanks for the quick response,

here: https://svelte.dev/playground/57847eba179f4fd1ae736fc4554c0700?version=3.59.2

try to scroll through the list using touch input

@NotLatif
Copy link
Author

Ok so I was able to find this example REPL
but it didn't handle touch inputs, so I edited it REPL if someone needs it

It's not perfect but it's fine for now

Issues with my REPL (skill issue)

  • text tries to gets selected on mobile for long presses,
  • sometimes the page scrolls with the item you're dragging)

I'll maybe come back another day to fix those

(maybe my use case is too specific) but otherwise it would be nice if svelte-dnd-action handled this someway for touch input users

@isaacHagoel
Copy link
Owner

isaacHagoel commented Nov 13, 2024 via email

@NotLatif
Copy link
Author

that's what I'm currently doing, it just looks better when it's full page wide for my current layout (yt shorts example)

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