Merged
Conversation
Replace confusing bind/call pattern where modules array was used as `this` context with a clean object-oriented approach: - Remove global carouselInstance variable (no longer needed) - buildModulesContext() now returns clean context object instead of mutating array with properties - moduleTransition() uses this.modulesContext instead of array-as-this - Extract selectWrapper() as standalone method - Simplify showModulesForSlide() to use for...of loops - manualTransition as arrow function closure Benefits: - Clearer code: this always refers to carousel instance - Better separation: modules array vs configuration object - More maintainable: standard OOP pattern - Easier to understand: no "clever" bind/call tricks
Replace mixed setInterval/setTimeout approach with recursive setTimeout pattern for cleaner and more maintainable timer management. Changes: - Remove all setInterval usage, use only setTimeout - Remove all clearInterval calls, only clearTimeout needed - Centralize timer logic in scheduleNextTransition() - Remove setupAutomaticTransitions() helper (no longer needed) - Schedule next transition after fade completes in moduleTransition() - Simplify restartTimer() to delegate to scheduleNextTransition() - Remove unused defaultTimer from context object - Remove timer parameter from buildModulesContext() Benefits: - Single timer type = simpler code - No timer type confusion (interval vs timeout) - All timer modes handled in one place - More flexible per-transition timing - No setInterval drift issues
- Replace parseInt() with Number() for cleaner type conversion - Add explicit validation using Number.isInteger() and bounds checking - Use guard clause pattern instead of try/catch blocks - Simplify object validation (payload && payload.slide) - Reduce from 18 to 16 lines while improving robustness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documentation
Code Refactoring
Chores