|
@@ -1042,6 +1042,7 @@ function nseBgImageEditor() {
|
|
|
img.onload = () => {
|
|
img.onload = () => {
|
|
|
imageWidth = img.naturalWidth;
|
|
imageWidth = img.naturalWidth;
|
|
|
imageHeight = img.naturalHeight;
|
|
imageHeight = img.naturalHeight;
|
|
|
|
|
+
|
|
|
};
|
|
};
|
|
|
img.src = imageUrl;
|
|
img.src = imageUrl;
|
|
|
|
|
|
|
@@ -1080,6 +1081,7 @@ function nseBgImageEditor() {
|
|
|
|
|
|
|
|
let dy = e.clientY - startY;
|
|
let dy = e.clientY - startY;
|
|
|
let newY = origY + dy;
|
|
let newY = origY + dy;
|
|
|
|
|
+ let valueInPourcentage = 50;
|
|
|
|
|
|
|
|
// 4) Contraintes sur le déplacement vertical
|
|
// 4) Contraintes sur le déplacement vertical
|
|
|
if (imageWidth && imageHeight) {
|
|
if (imageWidth && imageHeight) {
|
|
@@ -1094,16 +1096,22 @@ function nseBgImageEditor() {
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
// On borne verticalement
|
|
// On borne verticalement
|
|
|
- let minY = Math.min(containerHeight - (containerWidth * (imageHeight / imageWidth)), 0);
|
|
|
|
|
let maxY = 0;
|
|
let maxY = 0;
|
|
|
-
|
|
|
|
|
|
|
+ let minY = Math.min(containerHeight - (containerWidth * (imageHeight / imageWidth)), 0);
|
|
|
// Application des limites
|
|
// Application des limites
|
|
|
newY = Math.max(minY, Math.min(maxY, newY));
|
|
newY = Math.max(minY, Math.min(maxY, newY));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ console.log(minY, newY)
|
|
|
|
|
+ valueInPourcentage = (newY * 100) / minY;
|
|
|
|
|
+
|
|
|
|
|
+ console.log(valueInPourcentage)
|
|
|
|
|
+ element.style.backgroundPositionY = `${valueInPourcentage}%`;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// Application de la nouvelle position
|
|
// Application de la nouvelle position
|
|
|
- element.style.backgroundPositionY = `${newY}px`;
|
|
|
|
|
- console.log(newY);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|