Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/css/main.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 160 additions & 10 deletions dist/js/bundle.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions lib/js/idcrop/Handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Handle {
this.parent = parent;
this.offsetX = offsetX;
this.offsetY = offsetY;
this.point = new Point(point.x + offsetX, point.y + offsetY);
this.point = new Point(point.x, point.y);

this.node = document.createElement("div");
}
Expand All @@ -22,20 +22,20 @@ class Handle {
if (defaultStyles) this.node.className = "idwall-handle";
if (additionalClasses) this.node.classList.add(additionalClasses);
this.parent.appendChild(this.node);
this.node.style.left = this.point.x - this.node.offsetWidth / 2 + "px";
this.node.style.top = this.point.y - this.node.offsetWidth / 2 + "px";
this.node.style.left = (this.point.x + this.offsetX - ((this.node.offsetWidth) / 2)) + "px";
this.node.style.top = (this.point.y + this.offsetY - ((this.node.offsetWidth) / 2)) + "px";

var handleCreated = new CustomEvent("handleCreated", {
detail: [this.point.x, this.point.y]
detail: [this.point.x + this.offsetX, this.point.y + this.offsetY]
});
document.dispatchEvent(handleCreated);
}

setDirection(points) {
for (const [index, point] of points.entries()) {
if (
point.x === this.point.x - this.offsetX &&
point.y === this.point.y - this.offsetY &&
(point.x === this.point.x) &&
(point.y === this.point.y) &&
this.node.id === ""
) {
this.node.id = "direction-" + index;
Expand Down
1 change: 1 addition & 0 deletions lib/js/idcrop/IdCrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class IdCrop {

drawPreview(self) {
if (
self.config.containers.previewArea &&
typeof this.cropArea !== "undefined" &&
this.cropArea.isDrawing == false
) {
Expand Down
10 changes: 6 additions & 4 deletions lib/js/idcrop/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ class Polygon {
document.onmousemove = function(event) {
let x = event.clientX;
let y = event.clientY;
const halfHandleWidth = hdim / 2;
const correction = 1;

if (x < bounds.left) x = bounds.left;
if (x > bounds.right - hdim) x = bounds.right - hdim;
if (y < bounds.top) y = bounds.top;
if (y > bounds.bottom - hdim) y = bounds.bottom - hdim;
if (x < bounds.left - halfHandleWidth ) x = bounds.left - halfHandleWidth - correction;
if (x > bounds.right + halfHandleWidth - hdim) x = bounds.right + halfHandleWidth - hdim + correction;
if (y < bounds.top - halfHandleWidth) y = bounds.top - halfHandleWidth - correction;
if (y > bounds.bottom + halfHandleWidth - hdim) y = bounds.bottom + halfHandleWidth - hdim + correction;

that.resize(handle, direction, points, x, y, config);
};
Expand Down
Loading