Skip to content

Commit

Permalink
fix wrong calculated margin when css scale apply on video element
Browse files Browse the repository at this point in the history
  • Loading branch information
jparez committed Aug 6, 2024
1 parent e9eca0a commit 3414645
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/CoordinateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ module.exports = class CoordinateUtils {
if (this.hasLeftAndRightBorders()) {
return 0;
}
const videoRealSizeY = (this.video.videoHeight / this.video.videoWidth) * this.video.offsetWidth;
return (this.video.offsetHeight - videoRealSizeY) / 2;
const rect = this.video.getBoundingClientRect();
const videoRealSizeY = (this.video.videoHeight / this.video.videoWidth) * rect.width;
return (rect.height - videoRealSizeY) / 2;
}

/**
Expand All @@ -193,8 +194,9 @@ module.exports = class CoordinateUtils {
if (!this.hasLeftAndRightBorders()) {
return 0;
}
const videoRealSizeX = (this.video.videoWidth / this.video.videoHeight) * this.video.offsetHeight;
return (this.video.offsetWidth - videoRealSizeX) / 2;
const rect = this.video.getBoundingClientRect();
const videoRealSizeX = (this.video.videoWidth / this.video.videoHeight) * rect.height;
return (rect.width - videoRealSizeX) / 2;
}

calculateCoorFromPercent(x, y) {
Expand Down

0 comments on commit 3414645

Please sign in to comment.