Make sticky header implementation more robust #10663
Labels
APP: Learn
Re: Learn App (content, quizzes, lessons, etc.)
DEV: frontend
TAG: tech update / debt
Change not visible to user
Milestone
For topic pages, we implemented a logic
kolibri/kolibri/plugins/learn/assets/src/views/TopicsPage/index.vue
Lines 660 to 676 in 967a02d
that makes the sidebar sticky
The main idea of the current implementation is based on switching the sidebar between
position: absolute
andposition: fixed
. However, this approach, under certain circumstances (presence of the sidebar, page height), seems to be the main culprit of the jumping scrollbar problem described in #10414 (which contains a somewhat fragile solution).In the past, we used a different approach where we didn't switch
position
but re-calculated the top positionkolibri/kolibri/plugins/learn/assets/src/views/TopicsPage.vue
Lines 662 to 678 in c6a6095
however, that was one of the causes of the header being torn away from the sidebar completely (#8627) or temporarily which could be seen as the sidebar updating its position with delay, causing observable gaps between the sidebar and the header, as it took some time for the browser to re-render sidebar's top position.
Lastly, the current implementation is not very efficient as styles are re-calculated with each scroll event. There's throttling which helps, however, it could be improved further as there's no need to re-calculate styles under some conditions, for example when the sidebar is in its sticky state and we're scrolling down, we know that no change is needed.
It'd be good to think about a more robust and efficient approach that would also avoid the pitfalls of our previous implementation.
The text was updated successfully, but these errors were encountered: