idmillington / undum

A client-side framework for narrative hypertext interactive fiction.
https://idmillington.github.com/undum
MIT License
336 stars 80 forks source link

Change handling of scrolling after doWrite() #38

Closed sequitur closed 5 years ago

sequitur commented 9 years ago

The current behaviour for scrolling towards a recently written element in Undum can create presentation issues when a newly-created element (inserted into the DOM by doWrite()) is positioned very close to the top edge of its next sibling; in those instances, Undum has a tendency to scroll the viewport up such that the element is up against the viewport's bottom edge. This small change adds about 20% of the viewport's height to the point Undum moves the scroll to. This behaviour is especially nicer in situations when, for instance, content is written into an inline DOM element that's short enough that the next element is in the same line.