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

Auto scrolling #27

Closed
alexreardon opened this issue Aug 11, 2017 · 36 comments
Closed

Auto scrolling #27

alexreardon opened this issue Aug 11, 2017 · 36 comments

Comments

@alexreardon
Copy link
Collaborator

Current mitigation: use your trackpack or mouse to scroll while you are dragging. There was actually a lot of work done to make sure scroll is being listened to directly

Currently when dragging with a mouse the window will not automatically scroll. Nor will scroll containers automatically scroll. We could support this behaviour.

A few things to consider:

Scroll containers

  • Currently the library does not do too much with the DOM - it just works. Introducing a feature like this might require an additional export: a scrollable container. Perhaps also even an option for Droppables to support auto scrolling. Should it be opt in or default?
  • Window auto scrolling would be relatively simpler and could probably be turned on by default.
@kulakowka
Copy link
Contributor

Sounds cool. I've seen this behavior when dragging boards in trello.com. This is very convenient and it seems that this should work by default.

@alexreardon
Copy link
Collaborator Author

Yeah it is very convenient - just need the time to do it!

@alexreardon alexreardon modified the milestone: Candy Castle Aug 26, 2017
@tim-soft
Copy link

tim-soft commented Sep 3, 2017

I would personally love this feature, although I'm a little unsure of how I'd integrate auto scrolling into all of my other containers where applicable. DOM magic via CSS selectors?

@alexreardon
Copy link
Collaborator Author

I am super keen to work on this @tim-soft . We are currently working on #2 which is our primary focus for now. Once that ships I am really keen to get onto auto scrolling and touch support #11

We already know all the droppable scroll containers - so i am expecting we can create some interesting scroll propagator for them as well as the window. We will also need to consider keyboard and ensuring that the page / containers scroll as expected with that also

@kupkovski
Copy link

Hi guys. Congrats for the excellent work!
Do you have an estimate on how long will it take to be shipped?

@alexreardon
Copy link
Collaborator Author

@kupkovski I try not to give out time estimates - but this is huge priority for us. After we solve the big scale performance we will be on this like bees on honey - sweet glorious honey

@TimNZ
Copy link

TimNZ commented Dec 18, 2017

Sorry everyone, I'm going to look entitled and ungrateful, but auto scrolling is essential and should have been baked into v1.

Love everything about this library otherwise.

This library might be useful for inspiration and implementation time saving.

https://github.com/StreakYC/react-draggable-list

@alexreardon
Copy link
Collaborator Author

We are planning on working on it very soon. We also have a number of competing internal priorities. The plan is to work on it after #86 is shipped.

@jonaskello
Copy link

FWIW, react-sortable-hoc has this feature.

@alexreardon
Copy link
Collaborator Author

Yep. It will be added soon

@alexreardon
Copy link
Collaborator Author

I am now starting work on this. If there any great examples people are aware of feel free to post them. I am currently researching!

@joshuacrowley
Copy link

joshuacrowley commented Jan 16, 2018

https://app.asana.com and https://www.notion.so both have block based DnD, with autoscroll. Both seem to be built with React.

@TimNZ
Copy link

TimNZ commented Jan 16, 2018

I'll state the obvious - Trello :)

@alexreardon
Copy link
Collaborator Author

alexreardon commented Jan 16, 2018

Assorted thought on behaviour

Mouse / Touch

Window scrolling

Once the user gets close to the edge of the window and the window is able to be scrolled - then we scroll the window.

Droppable scrolling

If the user drags near the edge of a scrollable Droppable we scroll the droppable. If the user goes beyond the edge of the container we continue to scroll at maximum speed. This is unless we are now over the top of a new Droppable - in which case we stop auto scrolling

Priority

If an auto scroll would be activated for both the window and the Droppable at the same time then we give preference to [TO BE DECIDED]

Keyboard scrolling

If ever an item is moved within a list or into a new list and its location is partially invisible then the container or window will be scrolled so that it becomes visible.

Approach

I am still considering where the best place for this logic to live is. Initially I thought a redux middleware (or similar) location would be perfect - but we need to have access to the elements themselves to update their scroll which is not available from the state. Either we split the logic between Draggable and Droppable components which might get hard when it comes to prioritising types of auto scroll, or we put it in a location that has access to both - the dimension marshal. My initial thoughts are that I am not super keen to put it in the marshal as it extends its responsibilities - perhaps too far. 🤔... The challenge is we need a place that has access to the ref's as well as the dimensions in the state. Good times. Nice but bad idea if we put the DOM ref in the dimension state then we can access it from a middleware. This is bad as it breaks the idea of a serialised state..

Without breaking the redux principles the only place right now that has access to the DOM refs and the state is the dimension marshal. Otherwise we need components to also register themselves with another marshal - which feels like a lot of duplication and opportunity for inconsistencies

@alexreardon
Copy link
Collaborator Author

@jaredcrowe and I are white boarding behaviour

img_2548

@alexreardon
Copy link
Collaborator Author

git checkout -b auto-scroll

😄

@alexreardon
Copy link
Collaborator Author

Still in very early stages of fiddling around. But it is fun to play with!

early-auto-scroll

@alexreardon
Copy link
Collaborator Author

I am wrestling with an issue on mobile safari where a touchmove event provides an incorrect clientX / clientY value after a manually triggered scroll event. The values are then correct on the next touchmove 🙃. Still investigating if it is me or safari

lame-touch-move

@alexreardon
Copy link
Collaborator Author

I have raised a but in webkit about this one. I can reproduce it in an isolated example. After a scroll a touchmove does not correctly account for clientX, clientY intermittently.

I tried to create a work around for this but I was unable to given that:

  • it occurs intermittently
  • there can be a few incorrect touchmove events in a row (it could be 0 it could be 3 - or more!).
  • i have found no way to know if the touchmove event is accurate or not

Given that the webkit team is responding to the bug I will proceed with the bug exposed in the library. It sucks, but I cannot get around it at the moment. The result of this will be some jittering of a draggable as a window is auto scrolling on iOS11

@alexreardon
Copy link
Collaborator Author

alexreardon commented Jan 24, 2018

I think #291 is essential for auto scrolling to feel right so auto scrolling will be shipping with #291. Sadly #291 comes with a minor api break so it will push the version to 5.0 😊

@alexreardon
Copy link
Collaborator Author

It may seem a little quiet but this is well underway. There is a lot of complexity in doing this well for all of the different input types

@alexreardon
Copy link
Collaborator Author

alexreardon commented Jan 30, 2018

Here is our work in progress

  • mouse auto scroll for window and droppables
  • touch auto scroll for window and droppables
  • keyboard in a single list with window and droppable scroll
  • keyboard in multiple lists

We have put an extreme amount of love ❤️ into every interaction to make it feel great regardless of your page composition. We have also been giving keyboard lots of attention which is slowing things down a bit. Auto scrolling with a keyboard is a completely different beast to pointer input dragging

@tim-soft
Copy link

@alexreardon you're a wizard harry! Is this branch still React v15 compatible?

@alexreardon
Copy link
Collaborator Author

Yep @tim-soft

@alexreardon
Copy link
Collaborator Author

alexreardon commented Feb 2, 2018

This is the mess I am currently working through:

https://twitter.com/alexandereardon/status/959195944326643713

The browsers update document.documentElement.scrollTop and window.pageYOffset
differently as the window scrolls.

Webkit

documentElement.scrollTop: no update. Stays at 0
window.pageYOffset: updates to whole number

Chrome

documentElement.scrollTop: update with fractional value
window.pageYOffset: update with fractional value

FireFox

documentElement.scrollTop: updates to whole number
window.pageYOffset: updates to whole number

IE11 (same as firefox)

documentElement.scrollTop: updates to whole number
window.pageYOffset: updates to whole number

Edge (same as webkit)

documentElement.scrollTop: no update. Stays at 0
window.pageYOffset: updates to whole number

I have no idea if the rounding is the same between the browsers

@TimNZ
Copy link

TimNZ commented Feb 2, 2018

@alexreardon Sending you a virtual pat on the back, and a cup of tea with a biscuit.

@alexreardon
Copy link
Collaborator Author

I am drinking a tea right now!

☕️

@belief-cyf
Copy link

good luck

@Alebron23
Copy link

Alebron23 commented Feb 8, 2018

It just so happened that I sent you an email today inquiring about this feature before I found this post. Do you have an ETA when this feature will be ready?

@alexreardon
Copy link
Collaborator Author

We do not give out time estimates. It is actively being worked on so it should not be too much longer 👍

@alexreardon
Copy link
Collaborator Author

This is so close 🔥. There has been some really great work done to ensure this entire experience works in an initiative, beautiful and performant way with mouse, keyboard and touch. Getting keyboard working was a world of pain - but super worth it. It is looking fantastic

Thank you for your patience everyone

@alexreardon
Copy link
Collaborator Author

Branch just went green - getting closer!

screen shot 2018-02-20 at 4 11 02 pm

@alex6633
Copy link

Appreciate your efforts on this !!! 🥇
Need this feature very badly to make my component work.

@Alebron23
Copy link

You da man!!

@shruti8789
Copy link

shruti8789 commented Mar 28, 2019

Still in very early stages of fiddling around. But it is fun to play with!

early-auto-scroll

@alexreardon
Here, we can see a definite area after which it starts to auto-scroll (both above and down the pane/palette) . Can we customize this area?

@aalian66loop
Copy link

any updates on this ;(

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

No branches or pull requests