diff --git a/apps/demo/src/app/pages/view-transition/view-transition-page.component.html b/apps/demo/src/app/pages/view-transition/view-transition-page.component.html index 5f807ad7d..306007eb0 100644 --- a/apps/demo/src/app/pages/view-transition/view-transition-page.component.html +++ b/apps/demo/src/app/pages/view-transition/view-transition-page.component.html @@ -7,26 +7,30 @@

How to use

Basic example

-
-
- - Photo by - {{item.author}} - - + +
+
+ + Photo by + {{item.author}} + + +
-
-
- -
+
+ +
+ Photos provided by Pexels diff --git a/apps/demo/src/app/pages/view-transition/view-transition-page.component.ts b/apps/demo/src/app/pages/view-transition/view-transition-page.component.ts index 1685ebc90..5606ec2ad 100644 --- a/apps/demo/src/app/pages/view-transition/view-transition-page.component.ts +++ b/apps/demo/src/app/pages/view-transition/view-transition-page.component.ts @@ -1,6 +1,7 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Component} from '@angular/core'; -import {finalize} from 'rxjs'; +import {BehaviorSubject, takeUntil} from 'rxjs'; import {ViewTransitionService} from '@ng-web-apis/view-transition'; +import {TuiDestroyService} from '@taiga-ui/cdk'; interface Photo { src: string; @@ -8,7 +9,7 @@ interface Photo { url: string; } -const PHOTOS = [ +const PHOTOS: readonly Photo[] = [ { src: 'https://images.pexels.com/photos/16316785/pexels-photo-16316785/free-photo-of-fluffy-cat-on-blooming-tree-background.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1', author: 'Peng Louis', @@ -48,44 +49,39 @@ const USAGE_SAMPLE = ` templateUrl: `./view-transition-page.component.html`, styleUrls: [`./view-transition-page.component.less`], changeDetection: ChangeDetectionStrategy.OnPush, + providers: [TuiDestroyService], }) export class ViewTransitionPageComponent { - codeSample = USAGE_SAMPLE; - activeIndex = -1; - showDetails = false; - detailInfo: Photo | undefined = undefined; - data = PHOTOS; + readonly codeSample = USAGE_SAMPLE; + readonly data = PHOTOS; + readonly activeIndex$ = new BehaviorSubject(-1); + readonly detailInfo$ = new BehaviorSubject(undefined); constructor( private readonly viewTransitionService: ViewTransitionService, private readonly cdr: ChangeDetectorRef, + private readonly destroy$: TuiDestroyService, ) {} open(index: number): void { - this.activeIndex = index; - this.detailInfo = this.data[index]; - this.cdr.detectChanges(); - + this.activeIndex$.next(index); this.viewTransitionService .startViewTransition(() => { - this.showDetails = true; + this.detailInfo$.next(this.data[index]); this.cdr.detectChanges(); }) + .pipe(takeUntil(this.destroy$)) .subscribe(); } close(): void { this.viewTransitionService .startViewTransition(() => { - this.showDetails = false; + this.detailInfo$.next(undefined); this.cdr.detectChanges(); + this.activeIndex$.next(-1); }) - .pipe( - finalize(() => { - this.activeIndex = -1; - this.detailInfo = undefined; - }), - ) + .pipe(takeUntil(this.destroy$)) .subscribe(); } } diff --git a/apps/demo/src/app/pages/view-transition/view-transition-page.module.ts b/apps/demo/src/app/pages/view-transition/view-transition-page.module.ts index 1fe5b3542..d4bc2aa8f 100644 --- a/apps/demo/src/app/pages/view-transition/view-transition-page.module.ts +++ b/apps/demo/src/app/pages/view-transition/view-transition-page.module.ts @@ -4,12 +4,14 @@ import {RouterModule} from '@angular/router'; import {CommonModule} from '@angular/common'; import {HighlightModule} from 'ngx-highlightjs'; import {TuiLinkModule} from '@taiga-ui/core'; +import {TuiLetModule} from '@taiga-ui/cdk'; @NgModule({ imports: [ CommonModule, HighlightModule, TuiLinkModule, + TuiLetModule, RouterModule.forChild([{path: '', component: ViewTransitionPageComponent}]), ], declarations: [ViewTransitionPageComponent], diff --git a/libs/view-transition/package.json b/libs/view-transition/package.json index 34a1939d8..9794fb516 100644 --- a/libs/view-transition/package.json +++ b/libs/view-transition/package.json @@ -1,6 +1,6 @@ { "name": "@ng-web-apis/view-transition", - "version": "3.0.2", + "version": "3.0.0", "description": "This is a library for declarative use of View Transition API with Angular", "keywords": [ "angular",