elevateweb / elevatezoom

1.02k stars 493 forks source link

add progress/loading function #110

Open Alkasih opened 9 years ago

Alkasih commented 9 years ago

Thanks for the plugin. I am using it in my web.

Now, I have images gallery based on ajax call which will load new different images based on user search.

For this, I need to give a progress function which will show gif image before the image is really done to be loaded by browser.

Can you help, please.

        fetch: function(imgsrc) {
            //get the image
            var self = this;
            var newImg = new Image();
            newImg.onload = function() {
                //set the large image dimensions - used to calculte ratio's
                self.largeWidth = newImg.width;
                self.largeHeight = newImg.height;
                //once image is loaded start the calls
                self.startZoom();
                self.currentImage = self.imageSrc;
                //let caller know image has been loaded
                self.options.onZoomedImageLoaded(self.$elem);
            }
            newImg.src = imgsrc; // this must be done AFTER setting onload

            return;

        },