Skip to content

add task solution#1772

Open
2bmakohon wants to merge 2 commits into
mate-academy:masterfrom
2bmakohon:develop
Open

add task solution#1772
2bmakohon wants to merge 2 commits into
mate-academy:masterfrom
2bmakohon:develop

Conversation

@2bmakohon
Copy link
Copy Markdown

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your gallery implementation meets all functional requirements and works correctly. The code properly implements event delegation on #thumbs, correctly uses closest('a') to handle clicks on both images and links, and properly updates the main image source and alt text. The DEMO link uses the correct GitHub Pages format. One issue to fix: In your event handler, you declare the parameter as newevent but then reference the global event variable instead. Change event.target to newevent.target and event.preventDefault() to newevent.preventDefault(). While this works in modern browsers due to the global event fallback, it's incorrect and could cause issues in certain contexts. Using the passed parameter is the proper approach. Minor suggestion: Consider adding visual feedback to indicate which thumbnail is currently selected (like an active border or opacity change). This is a common gallery pattern that improves user experience, though it's not required for functionality.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread src/scripts/main.js Outdated

// Знаходимо найближчий елемент <a> від того, на що клікнули
// .closest() шукає вгору по DOM — працює і якщо клікнули на <img>, і на <a>
const link = event.target.closest('a');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The parameter is named newevent but event (global) is used here. You should use newevent.target instead to correctly reference the event object passed to the handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants