Luperi / wheelzoom

Simple Javascript library for zooming IMG elements with the mousewheel.
MIT License
18 stars 7 forks source link

if img.src changes,wheelzoom is not work #1

Open maiseven opened 6 years ago

maiseven commented 6 years ago

if img.src changes,wheelzoom is not work.

demo

maiseven commented 6 years ago

Well, I found the solution. like this,

var i = 0;
var images;
    function load() {
        images = wheelzoom(document.querySelectorAll('img'), {zoom: 0.1, maxZoom: 10});
    }
    function change(){
        triggerEvent(images[0], 'wheelzoom.reset');
        triggerEvent(images[0], 'wheelzoom.destroy');
        if(i % 2 == 1){
            document.getElementById('img1').src="./img/img1.jpg";
        }else{
            document.getElementById('img1').src="./img/img2.jpg";
        }
        wheelzoom(document.querySelectorAll('img'), {zoom: 0.1, maxZoom: 10});
        i++;
    }
ErShakirAnsari commented 4 years ago

Even drag is not working once src has changed

function singleImageSelector(THIS) {
    singleImage.src = THIS.src;
    //--- wheelzoom

    var images = wheelzoom(document.getElementById("idImgSingleImage"), {zoom: 0.1, maxZoom: 20})               
}
yazidbouallagui commented 3 years ago

if loaded just change the background url in the style not the src attribute