[notes] avoid jiggling on _commit() by accounting for border widths
This commit is contained in:
parent
15aaedb951
commit
b6088f95c3
1 changed files with 4 additions and 4 deletions
|
@ -88,7 +88,7 @@ function renderEditor(noteDiv, note) {
|
||||||
dragStart = {
|
dragStart = {
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: e.pageY,
|
||||||
mode: getArea(e.offsetX, e.offsetY, noteDiv.offsetWidth, noteDiv.offsetHeight),
|
mode: getArea(e.offsetX, e.offsetY, noteDiv.clientWidth, noteDiv.clientHeight),
|
||||||
};
|
};
|
||||||
noteDiv.classList.add("dragging");
|
noteDiv.classList.add("dragging");
|
||||||
});
|
});
|
||||||
|
@ -113,7 +113,7 @@ function renderEditor(noteDiv, note) {
|
||||||
noteDiv.style.width = (note.width * scale) + (e.pageX - dragStart.x) + 'px';
|
noteDiv.style.width = (note.width * scale) + (e.pageX - dragStart.x) + 'px';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let area = getArea(e.offsetX, e.offsetY, noteDiv.offsetWidth, noteDiv.offsetHeight);
|
let area = getArea(e.offsetX, e.offsetY, noteDiv.clientWidth, noteDiv.clientHeight);
|
||||||
if(area == "c") {
|
if(area == "c") {
|
||||||
noteDiv.style.cursor = 'move';
|
noteDiv.style.cursor = 'move';
|
||||||
} else {
|
} else {
|
||||||
|
@ -126,8 +126,8 @@ function renderEditor(noteDiv, note) {
|
||||||
dragStart = null;
|
dragStart = null;
|
||||||
note.x1 = Math.round(noteDiv.offsetLeft / scale);
|
note.x1 = Math.round(noteDiv.offsetLeft / scale);
|
||||||
note.y1 = Math.round(noteDiv.offsetTop / scale);
|
note.y1 = Math.round(noteDiv.offsetTop / scale);
|
||||||
note.width = Math.round(noteDiv.offsetWidth / scale);
|
note.width = Math.round(noteDiv.clientWidth / scale);
|
||||||
note.height = Math.round(noteDiv.offsetHeight / scale);
|
note.height = Math.round(noteDiv.clientHeight / scale);
|
||||||
renderNotes();
|
renderNotes();
|
||||||
}
|
}
|
||||||
noteDiv.addEventListener('mouseup', _commit);
|
noteDiv.addEventListener('mouseup', _commit);
|
||||||
|
|
Reference in a new issue