Skip to content

Commit

Permalink
refactor(core): add tuiZonefreeScheduler for TuiScrollControls (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Sep 3, 2024
1 parent 760a2ce commit f76bf70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {AsyncPipe, NgIf} from '@angular/common';
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {WA_ANIMATION_FRAME} from '@ng-web-apis/common';
import {tuiZoneOptimized} from '@taiga-ui/cdk/observables';
import {tuiZonefreeScheduler, tuiZoneOptimized} from '@taiga-ui/cdk/observables';
import {tuiFadeIn} from '@taiga-ui/core/animations';
import {TUI_ANIMATIONS_SPEED, TUI_SCROLL_REF} from '@taiga-ui/core/tokens';
import {tuiToAnimationOptions} from '@taiga-ui/core/utils';
Expand All @@ -23,7 +23,7 @@ export class TuiScrollControls {

protected readonly options = tuiToAnimationOptions(inject(TUI_ANIMATIONS_SPEED));
protected readonly refresh$ = inject(WA_ANIMATION_FRAME).pipe(
throttleTime(300),
throttleTime(300, tuiZonefreeScheduler()),
map(() => this.scrollbars),
startWith([false, false]),
distinctUntilChanged((a, b) => a[0] === b[0] && a[1] === b[1]),
Expand Down
8 changes: 6 additions & 2 deletions projects/core/components/scrollbar/scrollbar.directive.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {Directive, inject, Input} from '@angular/core';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {WA_ANIMATION_FRAME} from '@ng-web-apis/common';
import {tuiScrollFrom, tuiZonefree} from '@taiga-ui/cdk/observables';
import {
tuiScrollFrom,
tuiZonefree,
tuiZonefreeScheduler,
} from '@taiga-ui/cdk/observables';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {TUI_SCROLL_REF} from '@taiga-ui/core/tokens';
import {merge, throttleTime} from 'rxjs';
Expand Down Expand Up @@ -37,7 +41,7 @@ export class TuiScrollbarDirective {
});

protected readonly styleSub = merge(
inject(WA_ANIMATION_FRAME).pipe(throttleTime(100)),
inject(WA_ANIMATION_FRAME).pipe(throttleTime(100, tuiZonefreeScheduler())),
tuiScrollFrom(this.el),
)
.pipe(tuiZonefree(), takeUntilDestroyed())
Expand Down

0 comments on commit f76bf70

Please sign in to comment.