1

The magiczoom documentation describes callbacks that will execute at given times, but it's unclear how to use or assign those callbacks.

For example, how would I print a console message onZoomReady?

The closest I've found is a MagicZoom.defaults.onready property, but it's unclear how to set it via javascript (my attempts aren't working as expected).

bryanbraun
  • 3,025
  • 2
  • 26
  • 38

2 Answers2

5

The callbacks are configured via mzOptions, for example:

var mzOptions = {
    onZoomReady: function() { … } }
;

Or:

var mzOptions = {};
mzOptions.onZoomReady = function() { … };
Dan Roberts
  • 517
  • 7
  • 13
  • Such callbacks as described above cannot be configured to change data-options. Instead, a separate callback can be set via the mzOptions, for example: `` – Dan Roberts Jun 03 '16 at 12:32
0

You can do something like this:

MagicZoom.registerCallback('onUpdate', 
    function() {
        console.log('onUpdated', arguments[0], arguments[1], arguments[2]);
    });

That will log stuff in the console like this:

onUpdated (id-of-mz-wraper) (html of old element) (html of new element)

Other options that you can use are as per the documentation:

MagicZoom.registerCallback('onZoomReady', function() {
  console.log('onReady', arguments[0]);
  });

MagicZoom.registerCallback('onZoomIn', function() {
  console.log('onZoomIn', arguments[0]);
  });

MagicZoom.registerCallback('onZoomOut', function() {
  console.log('onZoomOut', arguments[0]);
  });
Silas Palmer
  • 2,687
  • 1
  • 29
  • 30