Skip to content

Commit 2a0a77a

Browse files
authored
JI-5681 fix crop selector sizing in edge (#202)
* JI-5681 fix crop selector sizing in edge * JI-5681 fix floating point cropper selector dimensions * JI-5681 put back padding value
1 parent 6d76d65 commit 2a0a77a

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

libs/cropper.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function Cropper(options) {
9696
const parentBounds = this.canvas.parentElement.getBoundingClientRect();
9797
if (top) {
9898
const ySpan = this.selector.offsetTop + this.selector.offsetHeight;
99-
let top = event.pageY - parentBounds.top;
99+
let top = Math.round(event.pageY) - parentBounds.top;
100100
if (top < 0) {
101101
top = 0;
102102
}
@@ -108,7 +108,7 @@ function Cropper(options) {
108108
}
109109
if (left) {
110110
const xSpan = this.selector.offsetLeft + this.selector.offsetWidth;
111-
let left = event.pageX - parentBounds.left;
111+
let left = Math.round(event.pageX) - parentBounds.left;
112112
if (left < 0) {
113113
left = 0;
114114
}
@@ -120,7 +120,7 @@ function Cropper(options) {
120120
}
121121
if (bottom) {
122122
const maxHeight = this.canvas.offsetHeight - this.selector.offsetTop;
123-
height = event.pageY - parentBounds.top - this.selector.offsetTop;
123+
height = Math.round(event.pageY) - parentBounds.top - this.selector.offsetTop;
124124
if (height < 0) {
125125
height = 0;
126126
}
@@ -130,7 +130,7 @@ function Cropper(options) {
130130
}
131131
if (right) {
132132
const maxWidth = this.canvas.offsetWidth - this.selector.offsetLeft;
133-
width = event.pageX - parentBounds.left - this.selector.offsetLeft;
133+
width = Math.round(event.pageX) - parentBounds.left - this.selector.offsetLeft;
134134
if (width < 0) {
135135
width = 0;
136136
}
@@ -366,7 +366,7 @@ function Cropper(options) {
366366
this.mirror.width = width;
367367
this.mirror.height = height;
368368
this.mirrorContext.drawImage(this.image, selectedX, selectedY, selectedWidth, selectedHeight, 0, 0, width, height);
369-
this.mirror.toBlob(handleBlob(callback), 'image/png', 1);
369+
this.mirror.toBlob(handleBlob(callback), 'image/png');
370370
}
371371

372372
/**
@@ -388,7 +388,7 @@ function Cropper(options) {
388388
this.mirrorContext.rotate(90 * rotation * Math.PI / 180);
389389
this.mirrorContext.translate(-this.image.width / 2, -this.image.height / 2);
390390
this.mirrorContext.drawImage(this.image, 0, 0);
391-
this.mirror.toBlob(handleBlob(callback), 'image/png', 1);
391+
this.mirror.toBlob(handleBlob(callback), 'image/png');
392392
}
393393

394394
/**

styles/css/application.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

styles/scss/_h5peditor-image-edit-popup.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ body.h5p-editor-image-popup {
66
position: fixed;
77
top: 0;
88
left: 0;
9-
109
width: 100%;
1110
height: 100%;
12-
1311
background: rgba(0,0,0,0.8);
1412
padding: 3em 1em;
1513
box-sizing: border-box;
@@ -29,13 +27,6 @@ body.h5p-editor-image-popup {
2927
display: inline-block;
3028
position: relative;
3129
top: 0;
32-
left: 50%;
33-
height: auto;
34-
width: 100%;
35-
max-height: 100%;
36-
-webkit-transform: translateX(-50%);
37-
-ms-transform: translateX(-50%);
38-
transform: translateX(-50%);
3930
background: #fff;
4031
-webkit-box-sizing: border-box;
4132
-moz-box-sizing: border-box;

0 commit comments

Comments
 (0)