Skip to content

WP-144 tp-carousel component - #115

Draft
harshdeep-gill wants to merge 31 commits into
masterfrom
feature/WP-144-tp-carousel-component
Draft

WP-144 tp-carousel component#115
harshdeep-gill wants to merge 31 commits into
masterfrom
feature/WP-144-tp-carousel-component

Conversation

@harshdeep-gill

Copy link
Copy Markdown
Contributor

No description provided.

@harshdeep-gill
harshdeep-gill marked this pull request as draft May 22, 2025 13:09
Comment thread src/carousel/index.html Outdated
<body>
<main>
<!--Infinite basic carousel-->
<tp-carousel infinite="yes" infinite="yes">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Let's remove duplicate attributes.

Comment thread src/carousel/style.scss Outdated

tp-carousel-slides {
overflow-y: visible;
overflow-x: auto;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Let's align this.

Comment thread src/carousel/tp-carousel.ts Outdated
constructor() {
// Initialize parent.
super();
this.slides = this.querySelectorAll( 'tp-carousel-slide' );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Let's add an empty line with a comment here.

Comment thread src/carousel/tp-carousel.ts Outdated
super();
this.slides = this.querySelectorAll( 'tp-carousel-slide' );
this.slideTrack = this.querySelector( 'tp-carousel-slides' );
this._observer = new IntersectionObserver( this.attributeChangeOnScroll?.bind( this ), { root: this.slideTrack, threshold: 0.999 } );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Do we need to be that strict to use 0.999 for 100% visibility of the element, or 0.99 should be enough?
Being too strict might not trigger if the root container clips a pixel or two due to rounding or scroll position.

Comment thread src/carousel/tp-carousel.ts Outdated
const index = Array.from( this.slides ).indexOf( entry.target );

// Update current slide index based on if it is is right or left scroll.
if ( index + 1 - ( this.perView - 1 ) > this.currentSlideIndex ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Let's hold this into a variable above to make it more readable.
index + 1 - ( this.perView - 1 )

Comment thread src/carousel/tp-carousel.ts Outdated
setTimeout( () => {
// Set the flag to false.
this.isProgramaticScroll = false;
}, 500 );

@imranhsayed imranhsayed May 26, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill I believe 500ms is dependent on user scroll. What if it takes longer than that to scroll? Can we define a config?
Something to consider for future is setting this to false onscrollEnd event. But it's currently not supported in all browsers.

Comment thread src/slider/index.html Outdated
<main>
<!--Slider that slides horizontally with responsive settings.-->
<tp-slider swipe-threshold="210" flexible-height="yes" infinite="yes" swipe="yes" responsive='[{"media":"(min-width: 600px)","flexible-height":"yes","infinite":"no","swipe":"yes","auto-slide-interval":2000,"per-view":1,"step":2},{"media":"(min-width: 300px)","flexible-height":"yes","infinite":"no","swipe":"yes","behaviour":"fade","auto-slide-interval":2000,"per-view":1,"step":1}]'>
<tp-slider swipe-threshold="210" flexible-height="yes" infinite="yes" swipe="yes" responsive='[{"media":"(min-width: 600px)","flexible-height":"yes","infinite":"no","swipe":"yes","auto-slide-interval":2000,"per-view":2,"step":2},{"media":"(min-width: 300px)","flexible-height":"yes","infinite":"no","swipe":"yes","behaviour":"fade","auto-slide-interval":2000,"per-view":1,"step":1}]'>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Please make a separate PR for changes in each component like slider and tooltip resp, so that one pr is responsible for one component and it's easy to track the changes in the future.

Comment thread webpack.config.js
entry: {
modal: './src/modal/index.ts',
slider: './src/slider/index.ts',
newSlider: './src/carousel/index.ts',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Can we this be called carousel?

Comment thread src/carousel/style.scss Outdated
overflow-x: auto;
scroll-snap-type: x mandatory;
display: flex;
scrollbar-width: none;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Is this tested on on major browser?

Comment thread src/carousel/tp-carousel.ts Outdated
if ( entry.isIntersecting && entry.target instanceof TPCarouselSlideElement && this.slides ) {
const index = Array.from( this.slides ).indexOf( entry.target );

// Update current slide index based on if it is is right or left scroll.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshdeep-gill Let's remove the duplicate words is is

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.

6 participants