C2DH / journal-of-digital-history

frontend app for our Digital Journal
GNU General Public License v3.0
20 stars 4 forks source link

Fix/scroll into view #488

Closed danieleguido closed 2 years ago

danieleguido commented 2 years ago

This PR aims at fixing the scrollintoView bug when dynamic content is present. Scenario: user click on the ToC or click to on one cell in the article fingerprint vis to reach a specific paragraph in the article. If there is dynamically added content above the desired paragraph, like images and javascript powered datavis, the scrollIntoView() method does not work, as it would align to the wrong position.

Solution I've added a rule of thumb of 50% window height to each Figure in the article and the possibility of setting the aspect ratio or the height in px directly from cell tags (more details below in a comment of this PR).

For dynamic content this fixed height is applied as minHeight to avoid the presence of a scrollbar, then there's basically no difference from what we got before. In most cases, those scripts set a fixed height themselves that they more or less respect (with the annoying message "bokeh is loaded." that add random vertical height to the box); in other cases, the .5% of window height is enough to make the desired paragraph visible on the page. Instead, for images. The result is this below, with floating images in the middle of the fixed height box (in grey, just to make it visible here):

Screenshot 2022-11-14 at 11 51 44
danieleguido commented 2 years ago

The default behaviour is that each figure has a fixed height of half browser height. This can be changed using cell tags:

eliselavy commented 2 years ago

@danieleguido problem by using the fingerprint functionnality and by trying to dispaly the article: http://localhost:3000/en/article/JJszM3GwAYDs http://localhost:3000/en/article/JJszM3GwAYDs?idx=101&layer=hermeneutics Screenshot 2022-11-14 at 14 42 08

eliselavy commented 2 years ago

ok for h-valuepx need to look at: for aspect-ratio- http://localhost:3000/en/notebook-viewer/JTJGcHJveHktZ2l0aHVidXNlcmNvbnRlbnQlMkZqZG[…]RLQmpSJTJGZmVhdHVyZS1yYXRpbyUyRkpESF9BcnRpY2xlLmlweW5i?idx=13