How to correct the zoom lens so that it does not jump and so that it is displayed according to the image it is on and shows the result of the image

How can I prevent the lens from jumping when it is on the first image and show the result of the zoom correctly on the div of the zoom result and how can I make the lens appear on the other images, not just on the first one as it is in the gif if not, follow the cursor and the position of the other images, it seems that the result of the zoom with the position of the cursor is correct

enter image description here

I am using grid to display in a grid or ruler the images to which the zoom effect is applied.

this is my css code:

.imagen__cont__zoom .grid_contenedores {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.imagen__cont__zoom .cont__img {
    width: 100%;
    overflow: hidden;
}

.imagen__cont__zoom .cont__img img {
    width: 300px;
    height: 300px;
    /*object-fit: cover;*/
}

.img__zoom__lente {
    position: absolute;
    border: 1px solid #d4d4d4;
    width: 40px;
    height: 40px;
}

.img__zoom__resultado {
    border: 1px solid #d4d4d4;
    width: 300px;
    height: 300px;
}

In the html I am adding several images to which I am applying zoom

this is my html code:

<div class="imagen__cont__zoom">
<div class="grid_contenedores">
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?city,night" alt="Girl">
</div>
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?space,night" alt="Girl">
</div>
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?montain,night" alt="Girl">
</div>
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?night" alt="Girl">
</div>
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?beach" alt="Girl">
</div>
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?vector" alt="Girl">
</div>
<div class="cont__img">
<img class="img__zoom" src="https://source.unsplash.com/random/?winter" alt="Girl">
</div>
</div>
<div class="img__zoom__lente"></div>
<div class="img__zoom__resultado"></div>
</div>

I think that the way I do the calculations for the position of the lens is wrong, that is why it is not shown according to the image where the lens is positioned, that is, in the real position of the cursor.

this is my javascript code:

    var imgs, lens, result, cx, cy;
imgs = document.querySelectorAll('.img__zoom');
result = document.querySelector('.img__zoom__resultado');
lens = document.querySelector('.img__zoom__lente');

// Función para mover la lente
function moveLens(e) {
var pos, x, y, img;

// Calcula la posición de la lente
pos = getCursorPos(e);
x = pos.x - (lens.offsetWidth / 2);
y = pos.y - (lens.offsetHeight / 2);
img = e.target;

// Evita que la lente se salga de la imagen
if (x > img.width - lens.offsetWidth) {x = img.width - lens.offsetWidth;}
if (x < 0) {x = 0;}
if (y > img.height - lens.offsetHeight) {y = img.height - lens.offsetHeight;}
if (y < 0) {y = 0;}

// Establece la posición de la lente
lens.style.left = x + "px";
lens.style.top = y + "px";

// Calcula la relación entre el resultado y la lente
cx = result.offsetWidth / lens.offsetWidth;
cy = result.offsetHeight / lens.offsetHeight;

// Ajusta el tamaño del resultado
result.style.backgroundSize = (img.width * cx) + "px " + (img.height * cy) + "px";

// Muestra el resultado
result.style.backgroundImage = "url('" + img.src + "')";
result.style.backgroundPosition = "-" + (x * cx) + "px -" + (y * cy) + "px";
}

// Función para obtener la posición del cursor
function getCursorPos(e) {
var a, x = 0, y = 0;
e = e || window.event;
a = e.target.getBoundingClientRect();
x = e.pageX - a.left;
y = e.pageY - a.top;
x = x - window.pageXOffset;
y = y - window.pageYOffset;
return {x : x, y : y};
}

// Agrega el evento de movimiento del mouse a cada imagen y a la lente
imgs.forEach(function(img) {
img.addEventListener("mousemove", moveLens);
});
lens.addEventListener("mousemove", moveLens);

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật