Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CYF-ITP-South Africa | Serna Malala | Module-Data-Groups | Week 3 Carousel Slideshow #286

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sernamalala
Copy link

@sernamalala sernamalala commented Jan 10, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

I have implemented level 1 and 2 of the slideshow exercise of creating an image carousel

Questions

Ask any questions you have for your reviewer.

@sernamalala sernamalala added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Participant to add when requesting review labels Jan 10, 2025
Copy link

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Code is neat and easy to understand.

  • When "auto forward" and "auto backward" happen concurrently, the slideshow app could behave "weirdly". Can you think of a solution to only allow at most one of them active at any given time?

  • You missed one requirement specified in readme.md.

  • UI/UX: When the user clicks the Forward/Backward button to move from one image to another, because the images have different dimensions, the buttons are displaced accordingly. Can you think of a way to make the buttons stay at the same location?

<div>
<button type="button" id="auto-backward-btn">Auto Backwards</button>
<button type="button" id="backward-btn">Backwards</button>
<button type="button" id="stop">Stop</button>
Copy link

Choose a reason for hiding this comment

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

Why not use a consistent naming convention for all buttons' id value.

Copy link
Author

Choose a reason for hiding this comment

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

I'll add the word "btn" to stop. I understand what you mean

Comment on lines 25 to 34
index++;
image.src = imagesArray[index];

}
else {
index = 0;
image.src = imagesArray[index];

}
Copy link

Choose a reason for hiding this comment

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

Can you think of a way (utilising the % operator) to simplify the code in lines 25-32 into 2 lines of code.

Copy link
Author

Choose a reason for hiding this comment

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

This was a bit tricky to think of, I had to take array lengths and look at how modulo operator works.


    index = (index + imagesArray.length + 1) % imagesArray.length;
    image.src = imagesArray[index];

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jan 14, 2025
@sernamalala
Copy link
Author

I have made the images be a certain height and width so that the buttons don't move

@sernamalala
Copy link
Author

The only thing that I can see that I missed out in the readme file would be adding the 4th image? I've added a 4th image into my images array.

@sernamalala
Copy link
Author

I already had the clearInterval set up for them to not run at the same time, I've made sure to clear instances and make them null if they should not be running.

@cjyuan
Copy link

cjyuan commented Jan 14, 2025

You could also consider using only one interval for both auto forward/backward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed Volunteer to add when completing a review 📅 Sprint 3 Assigned during Sprint 3 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants