Browse Source

HW19 edit undo

maryluis 4 năm trước cách đây
mục cha
commit
d8514d6c23
1 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 5 5
      homework19/script.js

+ 5 - 5
homework19/script.js

@@ -29,7 +29,7 @@ const tools = {
         },
         },
 
 
         mouseup(e){
         mouseup(e){
-            currentArray.push(current)
+
             current = null
             current = null
         }
         }
     },
     },
@@ -231,7 +231,7 @@ color.onchange = () => {
 }
 }
 
 
 document.getElementById('delete').onclick = () =>{
 document.getElementById('delete').onclick = () =>{
-    Drawable.instances = Drawable.instances.filter(item => !selection.includes(item))
+    Drawable.instances = [];
     selection = []
     selection = []
     Drawable.drawAll()
     Drawable.drawAll()
 }
 }
@@ -308,11 +308,11 @@ class Ellipse extends Drawable {
 
 
 let undo = document.getElementById("undo");
 let undo = document.getElementById("undo");
 undo.onclick = () =>  {
 undo.onclick = () =>  {
-
-    currentArray.pop()
+    debugger
+    Drawable.instances.pop()
     ctx.clearRect(0, 0, 400, 400);
     ctx.clearRect(0, 0, 400, 400);
 
 
-    for(let key of currentArray) {
+    for(let key of Drawable.instances) {
         if (key != 0) {
         if (key != 0) {
             key.draw()
             key.draw()
         }
         }