Magnifying glass for images
March 4, 2020 12:00 AM
Hey all,
Trying to get an awesome script to work, I found this thread with an example of a magnifying glass.
However, it only works in preview mode, as soon as I publish,
Would anyone be able/willing to help me out?
Here's the example: Magnifying Glass example
Discussion (4)
Here is an updated version that should work with the current version of Lectora.
awesome!!!
could you (try to) explain what's different, why does this work when the older version doesn't?
Well, there are a few issues with the old script.
- When trying to get the width and height of the original (full size) image, it needs to wait until the file finished loading. The comment indicates that it needs to wrap in .load but it actually doesn't do it. So the image size is not set and calculations do not work.
- jQuery selectors (.small, .large, etc) do not work partly due to the upgrade in Lectora for seamless play publish.
- The magnifier (the div and full size image) does not show up due to layering (need to set z-index).
- I also added loadPending flag to avoid duplicate loading of the full size image.
If you want to change the size of the magnifying glass you can update the magnifierSize variable in magnify.js. I got rid of the css and moved the style to the js file so you only have to add one file.
thank you so much!
It works like a gem, and I actually understand your explanation ;)
Discussions have been disabled for this post