feat(doc): move scroll-vd

This commit is contained in:
thomas
2023-10-18 09:49:19 +02:00
parent 0fae068682
commit a2d6f2471d
16 changed files with 26 additions and 26 deletions

View File

@@ -0,0 +1,53 @@
import { AsyncPipe, NgIf } from '@angular/common';
import { Component, HostListener } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Component({
standalone: true,
imports: [NgIf, AsyncPipe],
selector: 'app-root',
template: `
<div>Top</div>
<div>Middle</div>
<div>Bottom</div>
<button (click)="goToTop()" *ngIf="displayButton$ | async">Top</button>
`,
styles: [
`
:host {
height: 1500px;
display: flex;
flex-direction: column;
justify-content: space-between;
button {
position: fixed;
bottom: 1rem;
left: 1rem;
z-index: 1;
padding: 1rem;
}
}
`,
],
})
export class AppComponent {
title = 'scroll-cd';
private displayButtonSubject = new BehaviorSubject<boolean>(false);
displayButton$ = this.displayButtonSubject.asObservable();
@HostListener('window:scroll', ['$event'])
onScroll() {
const pos = window.pageYOffset;
this.displayButtonSubject.next(pos > 50);
}
goToTop() {
window.scroll({
top: 0,
left: 0,
behavior: 'smooth',
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ScrollCd</title>
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
<app-root></app-root>
</body>
</html>

View File

@@ -0,0 +1,4 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent).catch((err) => console.error(err));

View File

@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */

View File

@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';