Skip to content

AliceKLWilliams/Javascript-30-in-30

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Javascript-30-in-30

Javascript 30 in 30 Repo

Contains:

  1. Javascript Drum Kit
  • data- will allow us to add a custom attribute to HTML elements.

  • The event object passed to an event listener contains the 'keyCode' attribute, which we can use to determine which keyboard button has been pressed.

  • Audio HTML element can be selected and played in HTML using .play(). The audio will not play if it has already started, so we can reset the audio back to the start using .currentTime = 0;

  • We can listen for a CSS transition end using the "transitionend" event. The event object for this listener will contains the property 'propertyName'. This tells us the property that finished transitioning.

  1. CSS + JS Clock
  • We can use CSS to rotate elements using: transform:rotate(deg); By default this will use the centre of the element as the axis. To change this use the 'transform-origin' property. The value for this can be a percentage, with 100% being the rhs of the element, and 0% being the lhs.

  • SetInterval(, ); can be used to run every .

  1. Playing with CSS Variables and JS
  • We can declare variables in CSS using: --:val. To make these globally available we declare them in the :root element.

  • To use CSS variables we use var(--).

  • We can select multiple HTML elements using the .querySelectorAll() method. This returns a NodeList, which has less methods than an array.

  • The 'change' event handler can be used for detecting input change on sliders. The 'mousemouse' event handler can be used to detect the change AS it happens, not after.

  • element.dataset contains an object with all the data attributes and their values.

  • document.documentElement returns the root element of the page.

  • .style.setProperty(, ); can be used to set a CSS variable in JS.

  • CSS variables are scope based, so the closer variable with the same name as another is used instead of the further ones.

  1. Array Cardio Day 1
  • .filter(() => {}) can be used to filter down an array. which return true in function body will be in the returned array. We do not need to return false.

  • console.table() will display the objects in a table format.

  • .map((item) => {}); is used to return the same number of items as in the original array, but typically altered in some manner (e.g. only the .age value of each object).

  • .sort((a, b) => {}) is used to sort the array. Within the function body we will compare a and b. Return < 0 to have a come before b. Else return > 0 to have b before a.

  • .reduce((total, item) => {}, ) is used to reduce the array into a single value. is the running total, is the current item, and is the initial value of the counter. can be an object.

  • We can create an Array from a NodeList using Array.from().

  • .split() will split the string using into an array.

  1. Flex Panels Image Gallery
  • flex:1 on a flex children will have them equally use the remaining space in the parent. It is used as a proportion, between the children.
  1. Ajax Type Ahead
  2. Array Cardio Day 2
  3. Fun with HTML5 Canvas
  4. Dev Tool Domination
  5. Hold Shift to Check Multiple Checkboxes
  6. Custom HTML5 Video Player
  7. Key Sequence Detection
  8. Slide in on Scroll
  9. Javascript - Reference VS Copy
  10. LocalStorage and Event Delegation
  11. CSS Text Shadow Mouse Move Effect
  12. Sorting Band Names without Articles
  13. Tally String Times with Reduce
  14. Unreal Webcam Fun
  15. Native Speech Recognition
  16. Geolocation based Speedometer and Compass
  17. Follow Along Links
  18. Speech Synthesis
  19. Sticky Nav
  20. Event Capture, Propagation, Bubbling and Once
  21. Stripe Follow Along Dropdown
  22. Click and Drag to Scroll
  23. Video Speed Controller UI
  24. Countdown Clock
  25. Whack a Mole

About

Javascript 30 in 30

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages