Fix bug where coloring in same pixel and dragging over it with color prevents undo from working properly
This commit is contained in:
parent
cc8e2bbffb
commit
c2dd7a2b12
56
canvas.js
56
canvas.js
@ -130,20 +130,22 @@ document.addEventListener("DOMContentLoaded",()=>{
|
|||||||
if (e.target.tagName==="TH") {
|
if (e.target.tagName==="TH") {
|
||||||
if (mouseState>=0) {
|
if (mouseState>=0) {
|
||||||
var mycoords = getCoordinates(e.target)
|
var mycoords = getCoordinates(e.target)
|
||||||
if ("PIXELS" in changedPixels) {
|
if (!(e.target.id in changedPixels)) {
|
||||||
changedPixels["PIXELS"]+=","+mycoords.x+","+mycoords.y
|
if ("PIXELS" in changedPixels) {
|
||||||
} else {
|
changedPixels["PIXELS"]+=","+mycoords.x+","+mycoords.y
|
||||||
changedPixels["PIXELS"]=mycoords.x+","+mycoords.y
|
} else {
|
||||||
|
changedPixels["PIXELS"]=mycoords.x+","+mycoords.y
|
||||||
|
}
|
||||||
|
changedPixels["old_"+e.target.id]=e.target.style.background;
|
||||||
|
if (mouseState<2) {
|
||||||
|
e.target.style.background=selectedColor;
|
||||||
|
changedPixels[e.target.id]=selectedColor;
|
||||||
|
} else {
|
||||||
|
e.target.style.background="white";
|
||||||
|
changedPixels[e.target.id]="white";
|
||||||
|
}
|
||||||
|
changedPixels["STEPTYPE"]="ADD"
|
||||||
}
|
}
|
||||||
changedPixels["old_"+e.target.id]=e.target.style.background;
|
|
||||||
if (mouseState<2) {
|
|
||||||
e.target.style.background=selectedColor;
|
|
||||||
changedPixels[e.target.id]=selectedColor;
|
|
||||||
} else {
|
|
||||||
e.target.style.background="white";
|
|
||||||
changedPixels[e.target.id]="white";
|
|
||||||
}
|
|
||||||
changedPixels["STEPTYPE"]="ADD"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,20 +200,22 @@ document.addEventListener("DOMContentLoaded",()=>{
|
|||||||
if (!fillTool) {
|
if (!fillTool) {
|
||||||
if (e.target.tagName==="TH") {
|
if (e.target.tagName==="TH") {
|
||||||
var mycoords = getCoordinates(e.target)
|
var mycoords = getCoordinates(e.target)
|
||||||
if ("PIXELS" in changedPixels) {
|
if (!(e.target.id in changedPixels)) {
|
||||||
changedPixels["PIXELS"]+=","+mycoords.x+","+mycoords.y
|
if ("PIXELS" in changedPixels) {
|
||||||
} else {
|
changedPixels["PIXELS"]+=","+mycoords.x+","+mycoords.y
|
||||||
changedPixels["PIXELS"]=mycoords.x+","+mycoords.y
|
} else {
|
||||||
|
changedPixels["PIXELS"]=mycoords.x+","+mycoords.y
|
||||||
|
}
|
||||||
|
changedPixels["old_"+e.target.id]=e.target.style.background;
|
||||||
|
if (e.button===0) {
|
||||||
|
e.target.style.background=selectedColor;
|
||||||
|
changedPixels[e.target.id]=selectedColor;
|
||||||
|
} else {
|
||||||
|
e.target.style.background="white";
|
||||||
|
changedPixels[e.target.id]="white";
|
||||||
|
}
|
||||||
|
changedPixels["STEPTYPE"]="ADD"
|
||||||
}
|
}
|
||||||
changedPixels["old_"+e.target.id]=e.target.style.background;
|
|
||||||
if (e.button===0) {
|
|
||||||
e.target.style.background=selectedColor;
|
|
||||||
changedPixels[e.target.id]=selectedColor;
|
|
||||||
} else {
|
|
||||||
e.target.style.background="white";
|
|
||||||
changedPixels[e.target.id]="white";
|
|
||||||
}
|
|
||||||
changedPixels["STEPTYPE"]="ADD"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toolbar.style.visibility = "hidden";
|
toolbar.style.visibility = "hidden";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user