@rdlabo/ionic-angular-scroll-header 22.0.1-0 → 22.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -33
- package/docs/ion-content.md +30 -17
- package/docs/safe-area.md +2 -0
- package/docs/virtual-scroll.md +48 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
# @rdlabo/ionic-angular-scroll-header
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
This is directive for scroll with Header.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
### Choose by header layout
|
|
10
|
-
|
|
11
|
-
| Goal | Guide |
|
|
12
|
-
| --- | --- |
|
|
13
|
-
| Hide and reveal headers on IonContent | [IonContent](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/ion-content) |
|
|
14
|
-
| Coordinate headers with CDK virtual scroll | [Virtual Scroll](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/virtual-scroll) |
|
|
15
|
-
| Keep a native header always visible | [Safe Area](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/safe-area) |
|
|
16
|
-
|
|
17
|
-
## Quick start
|
|
18
|
-
|
|
19
|
-
After [Installation](#installation), attach the directive to `ion-content`. See [IonContent](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/ion-content).
|
|
3
|
+
Directives that hide and reveal Ionic headers while scrolling.
|
|
20
4
|
|
|
21
5
|
## Installation
|
|
22
6
|
|
|
@@ -24,29 +8,37 @@ After [Installation](#installation), attach the directive to `ion-content`. See
|
|
|
24
8
|
npm install @rdlabo/ionic-angular-scroll-header
|
|
25
9
|
```
|
|
26
10
|
|
|
27
|
-
|
|
11
|
+
Import the directive CSS globally (for example in `styles.css`):
|
|
12
|
+
|
|
13
|
+
```css
|
|
14
|
+
@import '@rdlabo/ionic-angular-scroll-header/css/scroll-header.directive.css';
|
|
15
|
+
```
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
+ @import '@rdlabo/ionic-angular-scroll-header/css/scroll-header.directive.css';
|
|
17
|
+
When using CDK virtual scroll, also set a bounded viewport:
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
```css
|
|
20
|
+
cdk-virtual-scroll-viewport {
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
.cdk-virtual-scroll-content-wrapper {
|
|
24
|
+
padding-top: inherit;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
40
27
|
```
|
|
41
28
|
|
|
29
|
+
## First success: IonContent
|
|
42
30
|
|
|
43
|
-
|
|
31
|
+
Build a page with enough scrollable rows and a header that can leave the viewport. See the complete example on [IonContent](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/ion-content).
|
|
44
32
|
|
|
45
|
-
|
|
33
|
+
Scroll down — the content header hides. Scroll up — it returns. Safe-area and always-visible native headers are covered on [Safe Area](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/safe-area). CDK viewports use [Virtual Scroll](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/virtual-scroll).
|
|
46
34
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
## Choose by header layout
|
|
36
|
+
|
|
37
|
+
| Goal | Guide |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| Hide and reveal headers on IonContent | [IonContent](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/ion-content) |
|
|
40
|
+
| Coordinate headers with CDK virtual scroll | [Virtual Scroll](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/virtual-scroll) |
|
|
41
|
+
| Keep a native header always visible | [Safe Area](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header/docs/safe-area) |
|
|
50
42
|
|
|
51
43
|
<!-- rdlabo-docs-omit -->
|
|
52
44
|
**Full documentation:** [https://docs.rdlabo.dev/projects/ionic-angular-scroll-header](https://docs.rdlabo.dev/projects/ionic-angular-scroll-header)
|
package/docs/ion-content.md
CHANGED
|
@@ -1,26 +1,39 @@
|
|
|
1
|
-
Attach scroll-aware headers to Ionic content. Call this after [Installation](../README.md#installation).
|
|
1
|
+
Attach scroll-aware headers to Ionic content. Call this after [Installation](../README.md#installation). Import the package CSS globally first. Safe-area hidden headers and always-visible native headers are covered on [Safe Area](./safe-area.md).
|
|
2
2
|
|
|
3
3
|
- Demo: https://rdlabo-ionic-angular-library.netlify.app/main/scroll-header
|
|
4
|
-
- Source: https://github.com/rdlabo-dev/ionic-angular-library/blob/
|
|
4
|
+
- Source: https://github.com/rdlabo-dev/ionic-angular-library/blob/v22.0.0/projects/demo/src/app/scroll-header/scroll-header.page.html
|
|
5
5
|
|
|
6
6
|
```ts
|
|
7
|
+
import { Component } from '@angular/core';
|
|
8
|
+
import { IonContent, IonHeader, IonItem, IonLabel, IonList, IonTitle, IonToolbar } from '@ionic/angular';
|
|
7
9
|
import { ScrollHeaderDirective } from '@rdlabo/ionic-angular-scroll-header';
|
|
10
|
+
|
|
8
11
|
@Component({
|
|
9
|
-
|
|
10
|
-
imports: [
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
selector: 'app-scroll-header',
|
|
13
|
+
imports: [IonContent, IonHeader, IonToolbar, IonTitle, IonList, IonItem, IonLabel, ScrollHeaderDirective],
|
|
14
|
+
template: `
|
|
15
|
+
<ion-header class="hidden">
|
|
16
|
+
<ion-toolbar></ion-toolbar>
|
|
17
|
+
</ion-header>
|
|
18
|
+
<ion-content rdlaboScrollHeader>
|
|
19
|
+
<ion-header>
|
|
20
|
+
<ion-toolbar>
|
|
21
|
+
<ion-title>Scroll header</ion-title>
|
|
22
|
+
</ion-toolbar>
|
|
23
|
+
</ion-header>
|
|
24
|
+
<ion-list>
|
|
25
|
+
@for (item of items; track item) {
|
|
26
|
+
<ion-item>
|
|
27
|
+
<ion-label>{{ item }}</ion-label>
|
|
28
|
+
</ion-item>
|
|
29
|
+
}
|
|
30
|
+
</ion-list>
|
|
31
|
+
</ion-content>
|
|
32
|
+
`,
|
|
13
33
|
})
|
|
34
|
+
export class ScrollHeaderPage {
|
|
35
|
+
readonly items = Array.from({ length: 40 }, (_, index) => `Row ${index + 1}`);
|
|
36
|
+
}
|
|
14
37
|
```
|
|
15
38
|
|
|
16
|
-
|
|
17
|
-
<ion-header class="hidden"><ion-toolbar></ion-toolbar></ion-header>
|
|
18
|
-
<!-- set hidden header for safe-area -->
|
|
19
|
-
<ion-content rdlaboScrollHeader>
|
|
20
|
-
<ion-header>
|
|
21
|
-
<ion-toolbar>...</ion-toolbar>
|
|
22
|
-
<!-- Default Header for display -->
|
|
23
|
-
</ion-header>
|
|
24
|
-
...Your Content
|
|
25
|
-
</ion-content>
|
|
26
|
-
```
|
|
39
|
+
Scroll down — the content header hides. Scroll up — it returns. The outer `ion-header.hidden` reserves safe-area space; see [Safe Area](./safe-area.md) when you need a different header layout.
|
package/docs/safe-area.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
Hidden safe-area headers and always-visible native headers.
|
|
2
2
|
|
|
3
|
+
Start from the scroll-aware header on [IonContent](./ion-content.md), then choose the header structure below for your layout.
|
|
4
|
+
|
|
3
5
|
## Why do I need to set hidden header for safe-area?
|
|
4
6
|
|
|
5
7
|
Of course, it is also possible to set a safe-area in ion-content as follows.
|
package/docs/virtual-scroll.md
CHANGED
|
@@ -1,51 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
Extend an existing CDK virtual-scroll viewport with scroll-aware headers. Start from [IonContent](./ion-content.md) for the header/safe-area pattern, then replace the scroll host with a viewport. Call this after [Installation](../README.md#installation).
|
|
2
2
|
|
|
3
3
|
- Demo: https://rdlabo-ionic-angular-library.netlify.app/main/virtual-scroll-header
|
|
4
|
-
- Source: https://github.com/rdlabo-dev/ionic-angular-library/blob/
|
|
4
|
+
- Source: https://github.com/rdlabo-dev/ionic-angular-library/blob/v22.0.0/projects/demo/src/app/virtual-scroll-header/virtual-scroll-header.page.html
|
|
5
5
|
|
|
6
6
|
```ts
|
|
7
|
+
import { Component } from '@angular/core';
|
|
8
|
+
import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
|
9
|
+
import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular';
|
|
7
10
|
import { VirtualScrollHeaderDirective } from '@rdlabo/ionic-angular-scroll-header';
|
|
8
11
|
|
|
9
12
|
@Component({
|
|
10
|
-
|
|
13
|
+
selector: 'app-virtual-scroll-header',
|
|
11
14
|
imports: [
|
|
12
|
-
|
|
15
|
+
IonContent,
|
|
16
|
+
IonHeader,
|
|
17
|
+
IonToolbar,
|
|
18
|
+
IonTitle,
|
|
19
|
+
CdkVirtualScrollViewport,
|
|
20
|
+
CdkVirtualForOf,
|
|
21
|
+
CdkFixedSizeVirtualScroll,
|
|
22
|
+
VirtualScrollHeaderDirective,
|
|
13
23
|
],
|
|
24
|
+
template: `
|
|
25
|
+
<ion-header class="hidden">
|
|
26
|
+
<ion-toolbar></ion-toolbar>
|
|
27
|
+
</ion-header>
|
|
28
|
+
<ion-content rdlaboVirtualScrollHeader>
|
|
29
|
+
<ion-header>
|
|
30
|
+
<ion-toolbar>
|
|
31
|
+
<ion-title>Virtual scroll header</ion-title>
|
|
32
|
+
</ion-toolbar>
|
|
33
|
+
</ion-header>
|
|
34
|
+
<cdk-virtual-scroll-viewport
|
|
35
|
+
minBufferPx="900"
|
|
36
|
+
maxBufferPx="1350"
|
|
37
|
+
[itemSize]="44"
|
|
38
|
+
class="ion-content-scroll-host"
|
|
39
|
+
>
|
|
40
|
+
<div *cdkVirtualFor="let item of items; trackBy: trackByFn" style="height: 44px">
|
|
41
|
+
{{ item }}
|
|
42
|
+
</div>
|
|
43
|
+
</cdk-virtual-scroll-viewport>
|
|
44
|
+
</ion-content>
|
|
45
|
+
`,
|
|
14
46
|
})
|
|
47
|
+
export class VirtualScrollHeaderPage {
|
|
48
|
+
readonly items = Array.from({ length: 80 }, (_, index) => `Row ${index + 1}`);
|
|
49
|
+
trackByFn = (_: number, item: string) => item;
|
|
50
|
+
}
|
|
15
51
|
```
|
|
16
52
|
|
|
17
|
-
|
|
18
|
-
<ion-header class="hidden"><ion-toolbar></ion-toolbar></ion-header>
|
|
19
|
-
<!-- set hidden header for safe-area -->
|
|
20
|
-
<ion-content rdlaboVirtualScrollHeader>
|
|
21
|
-
<ion-header>
|
|
22
|
-
<ion-toolbar>...</ion-toolbar>
|
|
23
|
-
<!-- Default Header for display -->
|
|
24
|
-
</ion-header>
|
|
25
|
-
<cdk-virtual-scroll-viewport
|
|
26
|
-
minBufferPx="900"
|
|
27
|
-
maxBufferPx="1350"
|
|
28
|
-
[itemSize]="44"
|
|
29
|
-
class="ion-content-scroll-host"
|
|
30
|
-
>
|
|
31
|
-
...Your Content
|
|
32
|
-
</cdk-virtual-scroll-viewport>
|
|
33
|
-
</ion-content>
|
|
34
|
-
```
|
|
53
|
+
Give the viewport a definite height via the global CSS from [Installation](../README.md#installation).
|
|
35
54
|
|
|
36
|
-
###
|
|
55
|
+
### Prevent scroll jump / flicker at the top
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
Addresses [angular/components#27104](https://github.com/angular/components/issues/27104) when an existing CDK viewport jumps back while scrolling.
|
|
58
|
+
|
|
59
|
+
Add the directive to the `imports` of the component above, then add its attribute to the existing viewport. Keep the CDK imports and data from that example.
|
|
39
60
|
|
|
40
61
|
```ts
|
|
41
62
|
import { FixVirtualScrollElementDirective } from '@rdlabo/ionic-angular-scroll-header';
|
|
42
63
|
|
|
43
|
-
@Component({
|
|
44
|
-
...
|
|
45
|
-
imports: [
|
|
46
|
-
FixVirtualScrollElementDirective
|
|
47
|
-
],
|
|
48
|
-
})
|
|
49
64
|
```
|
|
50
65
|
|
|
51
66
|
```html
|
|
@@ -57,7 +72,9 @@ import { FixVirtualScrollElementDirective } from '@rdlabo/ionic-angular-scroll-h
|
|
|
57
72
|
[itemSize]="44"
|
|
58
73
|
class="ion-content-scroll-host"
|
|
59
74
|
>
|
|
60
|
-
|
|
75
|
+
<div *cdkVirtualFor="let item of items; trackBy: trackByFn" style="height: 44px">
|
|
76
|
+
{{ item }}
|
|
77
|
+
</div>
|
|
61
78
|
</cdk-virtual-scroll-viewport>
|
|
62
79
|
</ion-content>
|
|
63
80
|
```
|