openseadragon / bookmark-url

An OpenSeadragon plugin for updating the zoom/pan in the page URL.
BSD 3-Clause "New" or "Revised" License
9 stars 4 forks source link

X and Y coordinates break in sequence mode? #2

Open kelynch opened 5 years ago

kelynch commented 5 years ago

Hello,

I'm using this plugin in a Rails application and noticed that the zoom functionality is preserved but not the x and y coordinates in the URL when you navigate to a page where the OSD viewer is in sequence mode. In collection mode, everything functions as expected. I suspect there might be an issue with the way in which I'm implementing the viewer:

Here's the code: https://github.com/upenn-libraries/bulwark/blob/feature/COLENDA-124-OSD_enhancements/app/assets/javascripts/colenda.js

https://github.com/upenn-libraries/bulwark/blob/feature/COLENDA-124-OSD_enhancements/app/views/catalog/_show_main_content.html.erb#L17-L19

Any guidance would be greatly appreciated!

iangilman commented 5 years ago

Interesting. I haven't tried it with sequence mode, so it probably just doesn't support it yet. For one thing, you'd want to keep track of the "page" of the sequence in addition to the other information.

I'm guessing what's happening is that the pan is being reset whenever you go to a new page, potentially including the very first page of the sequence mode. Probably the thing to do is watch for the page event and do some handling there.

Would you be up for modifying the bookmark URL code to address this?

BTW, if I'm correct about what's causing the issue, adding preserveViewport: true to your OSD options may also fix it, though it might have unwanted side effects.

kelynch commented 5 years ago

Thanks for your reply -- I'll take a stab at the code and submit a PR for review if I'm able to help. :)

iangilman commented 5 years ago

Awesome, thank you!

camdey commented 3 years ago

Not sure if this was subsequently fixed but just wanted to mention it is working as expected for me in sequence mode. I also added functionality to track the page in sequence mode and maintain both zoom and pan when loading a page (without using preserveViewport).

Let me know if it's worth submitting a PR, though I can't guarantee it's the best code!

iangilman commented 3 years ago

Interesting... I don't think there were any changes! Interesting that it's working now.

Does your new functionality have a switch that can turn it on and off? As long as it's optional, I'd love to add it in here! Pull requests are welcome, even if they aren't the best code ;)

camdey commented 3 years ago

@iangilman I've created a PR (#5). I made the page tracking optional but as I don't know javascript very well it may not be the best approach. Anyhow the code is working for me when used with the zoom-openseadragon WordPress plugin and latest OSD release.

iangilman commented 3 years ago

@camdey looks solid to me! I just had a couple small refinements to suggest. Thank you for doing this!