ilyashubin / scrollbooster

Enjoyable content drag-to-scroll library
https://ilyashubin.github.io/scrollbooster
MIT License
993 stars 80 forks source link

link drag issue #27

Closed pbuzdin closed 4 years ago

pbuzdin commented 4 years ago

Hi, Ilya!

If there are links in draggable container, they will be fire click event while dragging.

ilyashubin commented 4 years ago

Hello! Right now click event is not prevented by default. Maybe its a good idea to prevent any clicks by default, I'll think about it, thanks Right now you can do this:

new ScrollBooster({
  ...
  onClick: (state, event) => {
    // prevent default link event
    const isLink = event.target.nodeName.toLowerCase() === 'link';
    if (isLink) {
      event.preventDefault();
    }
  }
});
jos- commented 4 years ago

It would be better to still allow normal clicks. See https://github.com/donmbelembe/vue-dragscroll/issues/61#issuecomment-583951401 for a possible solution.

ilyashubin commented 4 years ago

Good workaround, thank you! For now I implemented drag offset based solution instead of timer based, because I have access to those metrics So preventDefault is called only when scrolled more than 5 pixels https://github.com/ilyashubin/scrollbooster/commit/15f826449875f8fcfdcc558882a661971f68e96d

jos- commented 4 years ago

Nice, thanks for the fix.

ilyashubin commented 4 years ago

This fix is in v2.2.2, closing