Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions events.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,69 @@ let hoverCard = document.querySelector('[data-secret="hover"]');
// 1. Add an event listener to reveal the image on hover.
// - The selector is hoverCard
// - The event type is mouseover
{
let image = document.querySelector('.hidden-image');
image.style.width = '100%';
image.style.height = '100%';
image.style.opacity = '1';
}
// (uncomment the code below and put it inside your event listener!)

// {
// let image = document.querySelector('.hidden-image');
// image.style.width = '100%';
// image.style.height = '100%';
// image.style.opacity = '1';
// }

// 2. Add an event listener to make the image hidden again.
// - The selector is hoverCard
// - The event type is mouseout
{
let image = document.querySelector('.hidden-image');
image.style.width = '0';
image.style.height = '0';
image.style.opacity = '0';
}
// (uncomment the code below and put it inside your event listener!)

// {
// let image = document.querySelector('.hidden-image');
// image.style.width = '0';
// image.style.height = '0';
// image.style.opacity = '0';
// }



const clickCard = document.querySelector('[data-secret="click"]');
// 3. Add an event listener to reveal and animate the shape on click.
// - The selector is clickCard
// - The event type is click
{
clickCard.classList.toggle('revealed');
}
// (uncomment the code below and put it inside your event listener!)

// {
// clickCard.classList.toggle('revealed');
// }


const doubleClickCard = document.querySelector('[data-secret="double-click"]');
// 4. Add an event listener to enlarge the text on double click.
// - The selector is doubleClickCard
// - The event type is dblclick
{
doubleClickCard.classList.toggle('revealed');
}
// (uncomment the code below and put it inside your event listener!)

// {
// doubleClickCard.classList.toggle('revealed');
// }


const keypressCard = document.querySelector('[data-secret="keypress"]');
// 5. Add an event listener to shake the card on any keypress.

// 5. Add an event listener to the DOCUMENT shake the keypress card on any keypress.
// - The selector is document
// - The event type is keydown
{
keypressCard.classList.add('revealed');
keypressCard.style.animation = "shake 0.5s";
}
// (uncomment the code below and put it inside your event listener!)

// {
// keypressCard.classList.add('revealed');
// keypressCard.style.animation = "shake 0.5s";
// }


// 6. Add an event listener to stop the shaking.
// - The selector is document
// - The event type is keyup
{
keypressCard.classList.remove('revealed');
keypressCard.style.animation = "";
}
// (uncomment the code below and put it inside your event listener!)

// {
// keypressCard.classList.remove('revealed');
// keypressCard.style.animation = "";
// }