Skip to content

Commit

Permalink
fix(kit): Carousel fix dragging in chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin committed Nov 29, 2024
1 parent c678696 commit e9301a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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

0 comments on commit e9301a8

Please sign in to comment.