JavaScript Project #1: Flashlight Effect

     To better sharpen my JavaScript skills, I will start building and posting random projects found on the Internet. I decided to attack a different approach to these projects. In the past, I've used tutorials or interactive web platforms in an attempt to master JS, but none of these have helped me learn the concepts. I can follow patterns and memorize code but I have not developed a deeper understanding. I find that I learn better when I have a good understanding of the foundations to build upon. 

    In one episode of the Scrimba podcast, an interviewee spoke about how the best way for her to learn was good old-fashioned pen and paper. She would write the code out to better help her remember it. Writing code sounds strange, but I figured it was worth a try. The first project I decided to build was a flashlight effect that I found here. Developed using HTML, CSS, and JS, it gives the effect of a flashlight shining across the computer screen as you move your mouse.

    The original code had the lorem ipsum text, but I replaced it with the ending from my favorite novel, The Great Gatsby by F. Scott Fitzgerald. I didn't change much else associated with the original code, outside of adding a <hr> break to add a separator between text. The project was simple and quick, but I spent a significant amount of time studying the lines of code and Googling concepets to get a better grasp of everything. The HTML was basic and I was familiar with most of the CSS, except using radial-gradient on the background property to create the flashlight circle on the page.

    As for the JavaScript, it implemented just two functions, with a try method inside of one of them to check to see if the device was touch screen or not. I am familiar with the try method from using it in projects during my Bootcamp course. I was not familiar with creating TouchEvents, pageX, pageY, and event.touches. I ended up reading articles from MDN and W3Schools to help me understand their functionality better. I have always had issues with X and Y coordinates. My first step to tackling the JS portion was to handwrite notes on what steps needed to be implemented. I then tried to write the code in VS just from my notes. Unfortunately, my note-taking skills weren't that great, so I ended up having to look back at the original code a couple of times. After typing the code out, I then tried to duplicate it with pen and paper, followed by typing it out in VS again. By that time, I had the code memorized.

    I have included a link below to the completed project.


Flashlight Effect



Comments

Popular posts from this blog

Learning WordPress

WordPress portfolio is live

My Coding Buddy