etch-a-sketch | HTML/CSS/JS project from The Odin Project

 by   rlmoser99 CSS Version: Current License: No License

kandi X-RAY | etch-a-sketch Summary

kandi X-RAY | etch-a-sketch Summary

etch-a-sketch is a CSS library. etch-a-sketch has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

This project is part the The Odin Project's curriculum.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              etch-a-sketch has a low active ecosystem.
              It has 2 star(s) with 2 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              etch-a-sketch has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of etch-a-sketch is current.

            kandi-Quality Quality

              etch-a-sketch has 0 bugs and 0 code smells.

            kandi-Security Security

              etch-a-sketch has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              etch-a-sketch code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              etch-a-sketch does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              etch-a-sketch releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of etch-a-sketch
            Get all kandi verified functions for this library.

            etch-a-sketch Key Features

            No Key Features are available at this moment for etch-a-sketch.

            etch-a-sketch Examples and Code Snippets

            No Code Snippets are available at this moment for etch-a-sketch.

            Community Discussions

            QUESTION

            Disable dragging in HTML webpage
            Asked 2022-Apr-15 at 09:20

            I'm trying to make an etch-a-sketch with HTML where I have a div container with lots of div elements in it, using grid display in CSS.

            HTML:

            Then I use JS to add the div elements:

            ...

            ANSWER

            Answered 2022-Apr-15 at 09:20

            You can use e.preventDefault() to prevent the default effect from happening inside your onmousedown event.

            Add e.preventDefault() inside your enableToggle(e) function

            Source https://stackoverflow.com/questions/71882017

            QUESTION

            TOP Etch-a-sketch grid resizing
            Asked 2022-Apr-03 at 05:59

            I'm trying to complete The Odin Project's Etch-a-Sketch challenge and am currently stuck with trying to resize the divs that make up the sketchpad. The app creates a 16x16 grid by default, and when pressing the erase button it asks for a number. It should then recreate the grid based on that number. However, after giving a number the size of the sketchpad is reduced. I have noticed that the number of empty divs created is always 256. Link to codepen for clarification: https://codepen.io/eerolli/pen/abELQbp

            Any help as to how I could get the size of the pad to stay the same regardless of the number of divs inside it is greatly appreciated.

            Edit: It should probably be noted, that the app works fine when I enter a number equal to or lower than 16.

            html:

            ...

            ANSWER

            Answered 2022-Apr-03 at 05:59

            You were super close ... you just need to call the create grid function again after the input prompt, and pass the new size/number the user entered as the argument ;D

            Edit: Ah yeah, I didn't notice it got stuck in a loop. I've refactored a little and added a couple of comments, hopefully helps.

            Source https://stackoverflow.com/questions/71705823

            QUESTION

            Range slider resetting to default on firefox
            Asked 2022-Mar-17 at 07:01

            So I'm making an Etch-a-Sketch with a range slider to change the grid size, but the slider keeps resetting to its default size (16x16) as soon as I move the mouse after changing the value (if I change the value and don't move the mouse, the size doesn't reset). For some reason this doesn't happen on Chrome: the value and grid size both change and stay that way until I change them again.

            Here's the JSFiddle: https://jsfiddle.net/CamiCoding/7zpt14cs/

            HTML:

            ...

            ANSWER

            Answered 2022-Mar-17 at 07:01

            I was able to track down the source of the issue, and fix it. Sounds weird, but document.body.onmousedown and document.body.onmouseup were creating the issue.
            Replacing them with addEventListener seems to fix it.

            I also removed some repeated code (in slider's input listener), by making maximum use of createGrid() function.

            Source https://stackoverflow.com/questions/71497690

            QUESTION

            Shading cells of a grid of "pixels" using javascript
            Asked 2022-Feb-23 at 01:19

            I'm working on sort of an Etch-a-Sketch project at the moment. The current issue im facing is how to make each cell of the grid incrementally get darker with every pass of the mouse cursor based on what the opacity of the cell being moused-over is. Currently whenever the cells of the grid are created it sets the background color to black and the opacity to 0, I have a function that I believe pulls the opacity of the current cell on mouseover and should increase that by 10% shadeCells(), however instead of doing that it just sets the opacity to 10% and each recurring pass of the mouse does nothing if the cell already has that 10% shade.

            ...

            ANSWER

            Answered 2022-Feb-23 at 01:19

            You'll have to force cell.style.opacity to be a Number before doing addition on it; the += isn't working:

            cell.style.opacity = Number(cell.style.opacity) + 0.1;

            Source https://stackoverflow.com/questions/71229543

            QUESTION

            setting width, height via setAttribute for a grid of divs - Etch-a-sketch. Style resets when hovered over
            Asked 2022-Feb-17 at 19:02

            I'm quite new to coding. I'm coding an Etch-a-sketch (via the Odin Project). Basically, it consists of a grid, which when hovered over, the boxes of the grid will change to a random color. (the container is supposed to keep the same dimensions) Upon loading the page, it starts with a basic grid of 16x16 boxes.

            The user also has the option to create a custom grid (for example, if the user enters 50, the container will be filled with 50x50 boxes, with their height and width adapted to fill the container)

            I seem to be stuck at this stage, when the button is clicked and you enter an amount of boxes, the grid will update. But then, when hovering over this 'custom' grid, the box size resets to the original width/height defined in the CSS.

            The boxes should keep their custom size when hovered over. (and when the color is changed)

            Below a codepen which will show the issue clearly, (enter a custom grid size(max 100 for performance) and hit enter).

            Codepen here with the full HTML/CSS/JS + example: Codepen

            ...

            ANSWER

            Answered 2022-Feb-17 at 19:02

            I thought I would update my initial question; after a few days of searching and updating the code, I found out that when using setAttribute to set the width and height of an element, and afterwards you use setAttribute to change only a style setting on the same element, it resets the width and height specified earlier via setAttribute. A way around this would be to specify the width and height again in the latest setAttribute call. Or instead of using setAttribute to set styling, you could do it via element.style.backgroundColor = 'color';

            So if anyone else runs into the same issue, hope it helps. :)

            Source https://stackoverflow.com/questions/71085377

            QUESTION

            JAVASCRIPT: change background color of a div, when hover over it while pressing the mouse click down
            Asked 2022-Feb-11 at 07:45

            I am trying to change the div background color when i hover over them clicking my mouse button.This is what i did so far. I want to make it like a drawing pen, so it won't change color when hover over but it will when hover over while pressing the mouse key.

            ...

            ANSWER

            Answered 2022-Feb-11 at 07:45

            I found this to work the best

            Source https://stackoverflow.com/questions/71075835

            QUESTION

            Issue with Javascript performance (Odin Project, Etch-a-Sketch)
            Asked 2022-Feb-07 at 22:11

            I'm currently learning Javascript on the Odin Project and I'm doing the Etch-a-Sketch exercise in which you're supposed to create a Etch-a-Sketch board you can draw on with your cursor. You're supposed to implement a resize button which allows the user to enter how many tiles they want on each side of the board, with a max value of 100 (for a 100x100 board). I did just that, and it technically works... except my browser starts chugging around 60 tiles, and crashed if I try to go for the max.

            The exercise teaches you how to use Javascript to manipulate the DOM, so I got my script to create a div container for the entire board, and a default 16x16 board is created when starting the page. Each tile is a div with an event listener assigned to it which detects when it's hovered. A new class is given to the tile, which changes its color according to the CSS rule tied to that class.

            The reset button calls a function when it's clicked. That function resets the classes for all tiles and prompts the user for a value. Once it gets a proper value, the CSS rule associated with the original div container gets updated with the requested amount of rows and columns, a function is called which removes all existing tiles, and another function fills the div container with new tiles.

            HTML

            ...

            ANSWER

            Answered 2022-Feb-07 at 22:11

            The performance problem is caused by placeEventListenersOnTiles(); being called within the for loop in generateUserGrid function.
            So each iteration adds more and more event listeners again and again.
            E.g. in 100x100 setup the first tile ends up with 10000 event listeners, the second one with 9999, and so on.

            Just move it outside of the loop:

            Source https://stackoverflow.com/questions/71024786

            QUESTION

            How do I get my etch-a-sketch program to "listen" to this dropdown menu instead of the buttons?
            Asked 2022-Feb-03 at 02:14

            I'm new to Stack Overflow. I hope that I'm doing this correctly. ❤

            I'm working on an old Etch-a-Sketch JavaScript project from months ago and decided to rework the 'mobile' form of the project because I hadn't bothered to do so at the time. At first, I tried just moving the buttons to the top horizontally, but I didn't like any of the variations I tried. So I decided I'd be better off with a dropdown menu instead that would appear when the screen is 500px or smaller, replacing the buttons.

            The dropdown menu is supposed to do exactly what the buttons do - when a certain mode is selected, that's the mode that the program is supposed to switch to. For example, when the "Party mode" button is clicked, the program switches to "party mode". I want the dropdown menu to behave similarly - when the "party mode" option is selected, the program should switch to "party mode".

            My logic was that I needed a function that grabbed the value of the dropdown menu, and then an "if" condition would run that pretty much says "If the value is x, x mode should run; else if the value is y, y mode should run", and so on. I added the function to the existing window.onload function so it would run upon the window loading. This didn't work.

            Note that the dropdown menu will, in the future, only appear when the screen size is 500px or less. In addition, I still have the buttons on the screen for all sizes, just for testing/debugging purposes. When I'm done and have this figured out, the buttons will have "display = 'none'" and be hidden for the "mobile size".

            Anyway, so yeah, the program is still just listening to the buttons, and not the dropdown menu. That leads me to believe that I need to somehow turn "off" the button mode? If that's the case, how do I do that? If that's not the case, what am I supposed to do here? Any help or insight would be greatly appreciated. Thanks!

            ...

            ANSWER

            Answered 2022-Feb-03 at 02:14

            Luckily, there's an easy way to do that. Add this piece of code into your javascript file and see the magic.

            Source https://stackoverflow.com/questions/70965071

            QUESTION

            EventListener doesn't trigger second time when passing a named function but triggers normally when passing the complete function
            Asked 2022-Jan-14 at 14:44

            I am trying to write a simple function for etch-a-sketch and came across this problem. I attached eventListener to the color and erase buttons like this:

            ...

            ANSWER

            Answered 2022-Jan-14 at 14:44

            What is lacking here is the ability to remove event listeners. Presently both erasing and coloring can happen at once on mouseover. Additionally, some booleans to track state will help guarantee the outcome.

            Source https://stackoverflow.com/questions/70712093

            QUESTION

            Trying to create 16x16 grid with flexbox but for some reason width: 100% won't work
            Asked 2021-Nov-12 at 13:40

            I'm trying to create a 16x16 grid with flexbox. I have set the width property of every 17th element to 100% and flex-wrap to wrap to achieve this. However, for some reason, my code doesn't work. I don't get the 16x16 grid on my page. How can I solve this?

            ...

            ANSWER

            Answered 2021-Nov-12 at 13:40

            You have a typo in your nth child (extra brackets) - if you remove this and then unstyle, your 17th divs, you should get your grid:

            Source https://stackoverflow.com/questions/69943484

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install etch-a-sketch

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/rlmoser99/etch-a-sketch.git

          • CLI

            gh repo clone rlmoser99/etch-a-sketch

          • sshUrl

            git@github.com:rlmoser99/etch-a-sketch.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link