Working with a non-React external library in a custom block

The problem is here:

        useEffect( () => {
            if ( ref.current ) {
                var panzoom = Panzoom(ref.current, {
                    minScale: 1.1,
                    maxScale: 5,
                    startScale: 1.1,
                    animate: true,
                    duration: 1000,
                    origin: '50% 0'
        }, []);

useEffect runs again when the dependencies parameter changes, but by providing none it will only run once.

If you want it to run again when the image URL changes, you need to declare that it depends on that variable so it re-runs when it changes