1

If I call MagicZoomPlus.stop(); on active magiczooms I'll frequently get the error:

Uncaught TypeError: Cannot read property 'width' of null

At other times I'll get this error:

Uncaught TypeError: Cannot read property 'r' of undefined 

When that happens, mousing over the thumbnails triggers:

Uncaught TypeError: Cannot read property 't16' of null 

I've tried ...

  • calling MagicZoomPlus.stop() within the onload event
  • calling MagicZoomPlus.stop() within a setTimeout of different lengths
  • calling MagicZoomPlus.stop() after testing for the presence of MagicZoomPlus
  • testing an image for width/height before calling MagicZoomPlus.stop()
  • setting width/height on images via css and attributes before calling MagicZoomPlus.stop()

Here's a link to a jsfiddle that uses markup copied from an example on their docs page: http://jsfiddle.net/sjjju4x4/6/

If you 'run' the fiddle with the console open you'll sometimes get the error, sometimes not. If you reduce the timeout to 10 ms it'll happen more often

Seems like I can't post without a code sample, so here's the JS from the fiddle:

var output = document.getElementById('status');
setTimeout(function () {
    document.getElementById('status').textContent = '...............calling stop';
    MagicZoomPlus.stop();
}, 20);

Thanks in advance for any help or suggestions you can provide.

1 Answers1

0

Please make sure that the MagicZoom instance is ready before calling MagicZoomPlus.stop().

It is possible to do this with the “onready” callback described at this URL below:

https://www.magictoolbox.com/magiczoomplus/integration/#api

Here is some sample code:

MagicZoomPlus.options = {
  'onready': function(id, isUpdated) {
     setTimeout(function () {
       document.getElementById('status').textContent = '...............calling stop';
       MagicZoomPlus.stop(id);
     }, 20);
  }
};

Here is a jsfiddle to help you see the code:

http://jsfiddle.net/pg9f98z0/

Dan Roberts
  • 517
  • 7
  • 13