igorlino / elevatezoom-plus

Enhanced elevateZoom - A jQuery image zoom plugin
http://igorlino.github.io/elevatezoom-plus/
MIT License
162 stars 78 forks source link

preloading/load on demand #86

Open Telrik opened 7 years ago

Telrik commented 7 years ago

Hi I use now original version. have problem i have like 200 thumbnails on page and if ez preloads ALL big images at start it's like take alot of time and traffic. i see in plugin code line
preloading: 1, //by default, load all the images, if 0, then only load images after activated (PLACEHOLDER FOR NEXT VERSION)

but it's never used.. so it's kinda not realized in this plus version of plugin as well ? right now i use this code .. problem is on onZoomedImageLoaded event zoom window is not appearing automatically.

  $('img.ezoom-ondemand').hover(function () {
            var _this = $(this);
            var elevateZoom = _this.data('elevateZoom');
            if (typeof elevateZoom === 'undefined') {
                _this.css('cursor', 'wait');
                _this.elevateZoom({
                    tint: true, scrollZoom: true, tintColour: '#337ab7', borderSize: 1, tintOpacity: 0.5, onZoomedImageLoaded: function () {
                        _this.css('cursor', 'pointer');
                    }
                });
            } else {
                //console.log('already');
                //elevateZoom.changeState('enable');
            }
        }
    );
igorlino commented 6 years ago

Ok, tricky question.

Maybe you can trigger manually the event you want?

element.trigger('the-event'); (http://api.jquery.com/trigger/)

What event? you have to decide on your code.

poebrand commented 6 years ago

Similar issue here... would like to load image on demand or at least have the option.

daniel-richter commented 5 years ago

My solution:

$("selector_for_your_images").each(function() {
  $(this).mouseover( function(event) { 
    $(this).ezPlus(); 
    $(this).unbind(event); 
  })
});

ezPlus is not initialized until the first mouseover (and thus the images are loaded on demand).