strawdynamics / drift

Easily add "zoom on hover" functionality to your site's images. Lightweight, no-dependency JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating zoom source during an active zoom

a2rampal opened this issue · comments

Not sure if there is already a way to do this, but I am building an application where I am constantly changing the image that data-zoom is referring to. Essentially zooming on a video and using the screenshots as the zoom source.

Problem I am running into is that every time I have mouseover on the element (video), the zoom image is the screenshot from the time at the start of the mouseover. If I move off the element and come back, the image has been updated.

Hmm… interesting use case. So you basically want it to act like a live viewfinder? How often are you updating the zoom source? I think the biggest issue here would be image load times, unless they're all already cached somehow. Thoughts?

I draw the video image to a canvas every 100ms to a second, so only one image is ever in play. Then I execute a toDataURL functon on the canvas to change what data-zoom is using.

I guess another question is how to toggle the Drift on and off. Thanks

Ah, so it's all local data. That makes things easier. I'm thinking I might just add a public API method for this. How does something like this sound to you?

EDITED:

var drift = new Drift(whateverSourceElement, {
  paneContainer: whateverContainerElement
});

function updateImage() {
  // draw to the canvas etc here

  drift.updateZoomImage();
}

I edited the above example, so you should click through to the thread to see that. Whoops!

drift.updateZoomImage();

sounds exactly like what I would need.

The other thing is that I click a zoom button to enable and disable zoom. Any idea on the best way to disable the Drift?

I suppose I should probably add that, as well. 🙂

I should be able to tackle these next week!

Hey @a2rampal, thanks for your patience on this! I've added + released as 0.4.0.

Hi

Can anyone help me on this issue ?

updateZoomImage doesn't work properly in Mozilla Firefox.
When changing the url for data-zoom, it doesn't show the loading screen. Instead it shows the previous image loaded. But this works perfectly in Google Chrome and Safari.

It happens when we use different image urls for setting src and data-zoom

@paulstraw

Hey @RosemolJ, can you set up a CodePen (or similar) showing this issue in action?