Skip to content

add task solution#1705

Open
RHerheman wants to merge 1 commit intomate-academy:masterfrom
RHerheman:develop
Open

add task solution#1705
RHerheman wants to merge 1 commit intomate-academy:masterfrom
RHerheman:develop

Conversation

@RHerheman
Copy link
Copy Markdown

- [DEMO LINK](https://RHerheman.github.io/js_task-move-spider-DOM/)

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

Great job implementing the core movement logic and handling page scroll correctly! Your use of getBoundingClientRect is a solid approach. However, I'm requesting a change because the current implementation doesn't fully support walls with different border sizes.

The code assumes all borders have the same width as the border-left-width. This leads to incorrect spider positioning if, for example, the border-top-width is different. This violates the requirement for the code to work with walls of any style.

To fix this, please adjust your calculations to account for individual border widths. You can get borderTopWidth and borderLeftWidth separately for the initial offset calculation. For the boundary checks, using the wall's clientWidth and clientHeight properties would be a more robust solution.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/scripts/main.js
const spiderRect = spider.getBoundingClientRect();
const spiderW = spiderRect.width;
const spiderH = spiderRect.height;
const borderWidth = parseInt(getComputedStyle(wall).borderLeftWidth);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This line assumes all borders of the wall have the same width as the left border. This will cause incorrect positioning if, for example, border-top-width is different. The clickY calculation on line 19 and the boundary calculations on lines 23 and 27 will be wrong. It's better to get each border width property (borderTopWidth, borderRightWidth, borderBottomWidth) and use them in their respective calculations.

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