79081579

Date: 2024-10-12 17:56:45
Score: 3
Natty:
Report link

You're currently using a static or hardcoded value for scrollPosition. Instead, you should calculate it based on the clicked item's position relative to the carousel and its width. This will ensure the clicked item is centered correctly.

const scrollPosition = itemOffset - (carouselWidth / 2) + (itemWidth / 2);

Please give it a try and let me know if it works

Reasons:
  • RegEx Blacklisted phrase (2.5): Please give
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Gaurav Jain