readium-shared-js icon indicating copy to clipboard operation
readium-shared-js copied to clipboard

Redraw highlight divs when the viewport is resized

Open jansc opened this issue 9 years ago • 4 comments

When the viewport of the cloud reader is resized, the highlights show up at apparently random locations. This is because the absolutely positioned highlight-divs are not repositioned when the window is resized.

Digging into the annotation module in Readium I saw that the code for redrawing the highlight divs is available in the redraw()-method, it's just never called. This patch solves the problem in the cloud reader, but I'm not sure if calling redrawHighlights from js/views/reader_view.js:handleViewportResize() is enough.

Any help would be appreciated!

Jan

jansc avatar Feb 27 '15 07:02 jansc

@JCCR @dmitrym0 I seem to remember you guys have a pretty good understanding of the execution flow for selection highlights (semi-transparent overlay divs). Could you please check @jansc suggested fix? Many thanks!

danielweck avatar Feb 27 '15 11:02 danielweck

Hi, sorry I just got a chance to look at this now.. @jansc Thanks for this PR. Calling it on reader_view:handleViewportResize() is not enough, you are right.

I would much rather like exposing this redrawHighlights as a public function in reader_view, so then who ever needs to use it, they can call it from a PAGINATION_CHANGED event callback or manually when needed. Calling it when this event triggers should cover all cases when they should be redrawn.

jccr avatar Mar 24 '15 16:03 jccr

Thanks for the feedback and sorry for the late answer. I'll update this pull request soon with redrawHighlights() as a public function in reader_view.

jansc avatar Apr 16 '15 06:04 jansc

I'm sorry it took so long to implement your suggestions, but now I've committed an update. If I got you right, the new reader_view.redrawHightlights() function is not to be called in reader_views PAGINATION_CHANGED callback but somewhere else, e.g. in readium-js-viewer's PAGINATION_CHANGED callback.

jansc avatar Jun 03 '15 07:06 jansc