Open paytonshaltis opened 1 year ago
Should take some time to decide how 'pages' will work in a carousel. Take the following for example, and consider a scrollBy
value of 3 and a wrapping method of either none
or wrap-smart
:
[1 2 3] 4 5 6 7 8 9 10 1 2 3 [4 5 6] 7 8 9 10 1 2 3 4 5 6 [7 8 9] 10 1 2 3 4 5 6 7 [8 9 10]
Scrolling to the right suggests 4 pages, but scrolling back suggests 4 different pages:
1 2 3 4 5 6 7 [8 9 10] 1 2 3 4 [5 6 7] 8 9 10 1 [2 3 4] 5 6 7 8 9 10 [1 2 3] 4 5 6 7 8 9 10
The best workaround for this situation is to simply do the following:
scrollBy
* ( |newPage - currentPage| ). So in this example, clicking on page 4 from 2 tries scrolling by 6. This should just stop right at the end.This means that carousels with scrollBy
values that do not go evenly into the total number of items will have different versions of pages, but there is no real way to avoid this.
Carousels that use wrap-simple will likely have even more combinations of pages due to the fact that they can roll over infinitely. Essentially, pages will just be quick ways of navigating X number of scrollBy
distances.
In order to prepare for the implementation of the timeline in #29 as well as the wrap-jump wrapping method in #53, some method for jumping to the desired page in the carousel should be created. Doing this before the issues mentioned above means that the process will be more streamlined.