ga-wdi-exercises / pixart_js

Use JS events and programmatically generated DOM elements to build a drawing application. [javascript, dom]
MIT License
9 stars 321 forks source link

W07d02 hw #20

Closed amaseda closed 9 years ago

amaseda commented 9 years ago

Comfort: 3 Completeness: 4

Got through part of bonus. Was able to generate swatches that save colors as new ones are entered. Did not, however, set the click event listener for them.

Also found that storing certain values in variables (e.g., swatchOne = swatches[0]) would cause later code not to work (e.g., swatchOne.style.backgroundColor = "blue" -- had to use swatches[0] instead of swatchOne).

Question: why does the event.preventDefault need to go inside the changeBrushBox function? I initially used it as the second argument in an addEventListener but it didn't work there.

jshawl commented 9 years ago

:+1:

Also found that storing certain values in variables (e.g., swatchOne = swatches[0]) would cause later code not to work (e.g., swatchOne.style.backgroundColor = "blue" -- had to use swatches[0] instead of swatchOne).

I'm unable to reproduce this, but let me know if you can! http://codepen.io/jshawl/pen/qddZpN?editors=101

Question: why does the event.preventDefault need to go inside the changeBrushBox function? I initially used it as the second argument in an addEventListener but it didn't work there.

Can you provide the non-working version? We talked about some of this today in class, but let me know if you'd like more help answering this question.