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

fix(kit): Carousel fix dragging in chrome #9864

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions projects/kit/components/carousel/carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {EMPTY_QUERY} from '@taiga-ui/cdk/constants';
import {TuiItem} from '@taiga-ui/cdk/directives/item';
import {TuiPan} from '@taiga-ui/cdk/directives/pan';
import type {TuiSwipeDirection} from '@taiga-ui/cdk/directives/swipe';
import {TuiSwipe} from '@taiga-ui/cdk/directives/swipe';
import {TUI_SWIPE_OPTIONS, TuiSwipe} from '@taiga-ui/cdk/directives/swipe';
import {TUI_IS_MOBILE} from '@taiga-ui/cdk/tokens';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {tuiClamp} from '@taiga-ui/cdk/utils/math';
Expand Down Expand Up @@ -44,6 +44,7 @@ import {TuiCarouselScroll} from './carousel-scroll.directive';
templateUrl: './carousel.template.html',
styleUrls: ['./carousel.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [{provide: TUI_SWIPE_OPTIONS, useValue: {timeout: 200, threshold: 30}}],
hostDirectives: [
{
directive: TuiCarouselDirective,
Expand Down Expand Up @@ -134,8 +135,8 @@ export class TuiCarouselComponent {
{intersectionRatio}: IntersectionObserverEntry,
index: number,
): void {
if (intersectionRatio && intersectionRatio !== 1 && !this.transitioned) {
this.updateIndex(index - Math.floor(this.itemsCount / 2));
if (intersectionRatio && intersectionRatio >= 0.5 && !this.transitioned) {
this.updateIndex(this.index < index ? index - this.itemsCount + 1 : index);
}
}

Expand Down
1 change: 1 addition & 0 deletions projects/kit/components/carousel/carousel.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
display: flex;
overflow: auto;
overscroll-behavior-x: none;
touch-action: none;

&::before,
&::after {
Expand Down
4 changes: 1 addition & 3 deletions projects/kit/components/carousel/carousel.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
>
<div
waIntersectionObserver
waIntersectionRoot
waIntersectionRootMargin="100px 1000000px 100px -51%"
waIntersectionThreshold="0,1"
waIntersectionThreshold="0.5"
class="t-wrapper"
>
<div
Expand Down
Loading