anka-213 / webcomic_reader

Webcomic Reader userscript at
https://openuserjs.org/scripts/anka-213/Webcomic_Reader
MIT License
120 stars 27 forks source link

images get weirdly stretched when switching pages #159

Open Owyn opened 2 years ago

Owyn commented 2 years ago

example url: https://exhentai.org/g/2057968/d411c07474/

video: https://user-images.githubusercontent.com/1309656/141286760-f661df51-36d4-4e96-bfd8-fbf1c481e952.mp4

settings: image

Browser: image

Script manager: TamperMonkey stable v4.13.6136

Owyn commented 2 years ago

also, before turning the page - current page is being scrolled all the way up to the top for no reason

SoraHjort commented 2 years ago

In terms of the first issue. What is going on is the archive has different sized and shaped images. The way the webcomic reader works is that it caches the image source data and then alters it's only comic tag with the src location when you navigate to and fro.

Meaning it has to recalculate the image size every time you switch a page. For most archives this isn't a problem as they have a more unified size. But with image sets and the like such as in your example, they can vary extremely, thus, the stretching issue occurs.

Can this be combatted? Maybe, but would likely require a bit of rewriting.

As for the second comment/issue, this is due to wcr's order of operations. It'll switch the image before auto scrolling up. In an ideal world this would occur at the same time. However the only "solution" I can think of that wouldn't require major work would to simply change the order to change the image first then scroll up.

But for those who use this script to read comics that may not be ideal since that would spoil the last panels before the scroll up.

This issue though tends to occur more noticeably on high resolution images or quite low end machines, due to the time it takes to do these change overs. The only other idea to cover it up would the image fade into the next page after scrolling up. This would require less of a rewrite, and more inserting stuff in the right place. It would be less visually jarring to have it scroll up then fade, than for it to scroll up and then pop to the next image. This would require some testing however.

I am currently working on updating my fork that I use to submit pulls to this project, if I remember after some of the more major stuff, I'll try to remember to test it. It would likely also require adding some settings in graphics to turn on/off as well as timing. But this might be a ways off.

Owyn commented 2 years ago

recalculate the image size every time you switch a page that would spoil the last panels before the scroll up.

Sounds like a desync-d timing issue tho

I was hoping attaching some events and doing stuff in the right time would fix it? (e.g. scrolling to top and changing img resolution only when the new image starts loading (gets its naturalWidth & height set already) Just so it would do things seemingly instantly without much waiting time like it is now

Maybe the desync is related to "force loading next page" not working? https://github.com/anka-213/webcomic_reader/issues/157 cuz it's supposed to show next image being loaded in real time with it and it currently doesn't

But anyway, thank you for your work.