Skip to content

Commit dfc0a4a

Browse files
committed
retain marker after paging
1 parent bd21855 commit dfc0a4a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

marker.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@
4848
rectDom.addEventListener ("mousemove", onMouseMove, false);
4949
}
5050
function onMouseMove (e) {
51-
draw();
51+
draw(true);
5252
_rectangle.endY = e.layerY - _rectangle.startY;
5353
_rectangle.endX = e.layerX - _rectangle.startX;
5454
context.lineWidth = 3;
5555
context.strokeStyle = "rgb(255, 0, 0)";
5656
context.strokeRect (_rectangle.startX, _rectangle.startY, _rectangle.endX, _rectangle.endY);
5757
}
5858
function onMouseUp (e) {
59-
draw();
60-
_rectangle = createRect();
59+
draw(true);
60+
// _rectangle = createRect();
6161
rectDom.removeEventListener ("mousemove", onMouseMove, false);
6262
}
6363

@@ -70,13 +70,15 @@
7070
};
7171
}
7272

73-
function draw() {
73+
function draw(update) {
7474
context.clearRect(0, 0, rectDom.width, rectDom.height);
7575
context.lineWidth = 3;
7676
context.strokeStyle = "rgb(255, 0, 0)";
7777
var r = _rectangle;
7878
context.strokeRect(r.startX, r.startY, r.endX, r.endY);
7979

80+
if (!update) { return; }
81+
8082
var n = normalize(_rectangle);
8183
if (n.endX * n.endY === 0) {
8284
document.getElementById('selected_area').innerText = '';
@@ -105,7 +107,7 @@
105107

106108
rectDom.addEventListener("mousedown", onMouseDown, false);
107109
rectDom.addEventListener("mouseup" , onMouseUp , false);
108-
imageDom.addEventListener('load', resize, false);
110+
imageDom.addEventListener('load', function() { resize(); draw(false); }, false);
109111

110112
renderPage();
111113
</script>

0 commit comments

Comments
 (0)