Reputation: 448
I'm trying to create an HTML5-canvas based web app with zooming-to-cursor functionality. The idea is simple:
I'm having troubles with the last step. When I load the first image, zoom in/out and then load the second image, I get the second image already zoomed to the scale of the previous image. I suppose the problem comes from trackTransforms
function (took it there), but I don't understand how it works, so I can't track down the issue.
Live code: https://jsfiddle.net/Arkonage/tgkv21s8/22/
Upvotes: 0
Views: 602
Reputation: 16875
As a quick and dirty solution:
ctx.save();
to the beginning of the trackTransforms()
function definition.ctx.restore(); ctx.save();
to the beginning of the resetCanvas()
function definition.Upvotes: 1