angular-overflow-indicator 0.1.0
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 +70 -0
- package/esm2022/angular-overflow-indicator.mjs +5 -0
- package/esm2022/index.mjs +2 -0
- package/esm2022/lib/default-indicator-button/default-indicator-button.component.mjs +24 -0
- package/esm2022/lib/default-indicator-button/index.mjs +2 -0
- package/esm2022/lib/scroll-view-with-indicator/index.mjs +2 -0
- package/esm2022/lib/scroll-view-with-indicator/scroll-view-with-indicator.component.mjs +65 -0
- package/fesm2022/angular-overflow-indicator.mjs +93 -0
- package/fesm2022/angular-overflow-indicator.mjs.map +1 -0
- package/index.d.ts +1 -0
- package/lib/default-indicator-button/default-indicator-button.component.d.ts +7 -0
- package/lib/default-indicator-button/index.d.ts +1 -0
- package/lib/scroll-view-with-indicator/index.d.ts +1 -0
- package/lib/scroll-view-with-indicator/scroll-view-with-indicator.component.d.ts +26 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# angular-overflow-indicator
|
|
2
|
+
|
|
3
|
+
This library includes a simple and performant component that displays a given button if the content of the component overflows.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### Button that displays/hides accordingly
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
### Observe the scroll state
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Basic Usage
|
|
17
|
+
|
|
18
|
+
**Step 1: Install the package**
|
|
19
|
+
|
|
20
|
+
```console
|
|
21
|
+
yarn add angular-overflow-indicator
|
|
22
|
+
```
|
|
23
|
+
or
|
|
24
|
+
```console
|
|
25
|
+
npm install angular-overflow-indicator
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Step 2: Install the package**
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { ScrollViewWithIndicatorComponent } from 'angular-overflow-indicator';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Step 3: Create a container with a maximum/fixed size**
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<div [style]="{ height: '300px', width: '500px' }">
|
|
38
|
+
// ...
|
|
39
|
+
</div>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Step 4: Add a template that includes the indicator-button**
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<div [style]="{ height: '300px', width: '500px' }">
|
|
46
|
+
<ng-template #customButton>
|
|
47
|
+
<button (click)="view.scrollToBottom()">There is more below <i>👇</i></button>
|
|
48
|
+
</ng-template>
|
|
49
|
+
|
|
50
|
+
// ...
|
|
51
|
+
</div>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Step 5: Add the overflow-indicator-component with a list larger than the outer container and pass the template reference of the indicator-button**
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<div [style]="{ height: '300px', width: '500px' }">
|
|
58
|
+
<ng-template #customButton>
|
|
59
|
+
<button (click)="view.scrollToBottom()">There is more below <i>👇</i></button>
|
|
60
|
+
</ng-template>
|
|
61
|
+
|
|
62
|
+
<ng-scroll-view-with-indicator #view [indicatorButton]="customButton">
|
|
63
|
+
<ul>
|
|
64
|
+
<li *ngFor="let item of items()">List item {{ item }}</li>
|
|
65
|
+
</ul>
|
|
66
|
+
</ng-scroll-view-with-indicator>
|
|
67
|
+
</div>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './index';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1vdmVyZmxvdy1pbmRpY2F0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItb3ZlcmZsb3ctaW5kaWNhdG9yL3NyYy9hbmd1bGFyLW92ZXJmbG93LWluZGljYXRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsU0FBUyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2luZGV4JztcbiJdfQ==
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from './lib/scroll-view-with-indicator';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItb3ZlcmZsb3ctaW5kaWNhdG9yL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGtDQUFrQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9saWIvc2Nyb2xsLXZpZXctd2l0aC1pbmRpY2F0b3InO1xuIl19
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class DefaultIndicatorButtonComponent {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.buttonClicked = new EventEmitter();
|
|
6
|
+
}
|
|
7
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultIndicatorButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
8
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.9", type: DefaultIndicatorButtonComponent, isStandalone: true, selector: "ng-scroll-view-default-indicator-button", outputs: { buttonClicked: "buttonClicked" }, ngImport: i0, template: `
|
|
9
|
+
<button class="default-button" (click)="buttonClicked.emit()">
|
|
10
|
+
<span>There is more content</span>
|
|
11
|
+
</button>
|
|
12
|
+
`, isInline: true, styles: ["button{border:none;font-size:.8rem;font-weight:500;padding:.4rem .6rem;background-color:#444;color:#fff;border-radius:1rem;margin-bottom:.4rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
13
|
+
}
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultIndicatorButtonComponent, decorators: [{
|
|
15
|
+
type: Component,
|
|
16
|
+
args: [{ selector: 'ng-scroll-view-default-indicator-button', template: `
|
|
17
|
+
<button class="default-button" (click)="buttonClicked.emit()">
|
|
18
|
+
<span>There is more content</span>
|
|
19
|
+
</button>
|
|
20
|
+
`, standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["button{border:none;font-size:.8rem;font-weight:500;padding:.4rem .6rem;background-color:#444;color:#fff;border-radius:1rem;margin-bottom:.4rem}\n"] }]
|
|
21
|
+
}], propDecorators: { buttonClicked: [{
|
|
22
|
+
type: Output
|
|
23
|
+
}] } });
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmYXVsdC1pbmRpY2F0b3ItYnV0dG9uLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvYW5ndWxhci1vdmVyZmxvdy1pbmRpY2F0b3Ivc3JjL2xpYi9kZWZhdWx0LWluZGljYXRvci1idXR0b24vZGVmYXVsdC1pbmRpY2F0b3ItYnV0dG9uLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsdUJBQ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gICAgYm9yZGVyLXJhZGl1czogMXJlbTtcbiAgICAgIG1hcmdpbi1ib3R0b206IDAuNHJlbTtcbiAgICB9XG4gIGAsXG4gIHN0YW5kYWxvbmU6IHRydWUsXG4gIGNoYW5nZURldGVjdGlvbjogQ2hhbmdlRGV0ZWN0aW9uU3RyYXRlZ3kuT25QdXNoXG59KVxuZXhwb3J0IGNsYXNzIERlZmF1bHRJbmRpY2F0b3JCdXR0b25Db21wb25lbnQge1xuICBAT3V0cHV0KCkgYnV0dG9uQ2xpY2tlZCA9IG5ldyBFdmVudEVtaXR0ZXIoKTtcbn1cbiJdfQ==
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { DefaultIndicatorButtonComponent } from './default-indicator-button.component';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItb3ZlcmZsb3ctaW5kaWNhdG9yL3NyYy9saWIvZGVmYXVsdC1pbmRpY2F0b3ItYnV0dG9uL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSwrQkFBK0IsRUFBRSxNQUFNLHNDQUFzQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IHsgRGVmYXVsdEluZGljYXRvckJ1dHRvbkNvbXBvbmVudCB9IGZyb20gJy4vZGVmYXVsdC1pbmRpY2F0b3ItYnV0dG9uLmNvbXBvbmVudCc7XG4iXX0=
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { ScrollViewWithIndicatorComponent } from './scroll-view-with-indicator.component';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9saWJzL2FuZ3VsYXItb3ZlcmZsb3ctaW5kaWNhdG9yL3NyYy9saWIvc2Nyb2xsLXZpZXctd2l0aC1pbmRpY2F0b3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGdDQUFnQyxFQUFFLE1BQU0sd0NBQXdDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBTY3JvbGxWaWV3V2l0aEluZGljYXRvckNvbXBvbmVudCB9IGZyb20gJy4vc2Nyb2xsLXZpZXctd2l0aC1pbmRpY2F0b3IuY29tcG9uZW50JztcbiJdfQ==
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, Output, signal, ViewChild } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { DefaultIndicatorButtonComponent } from '../default-indicator-button';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
import * as i1 from "@angular/common";
|
|
6
|
+
export class ScrollViewWithIndicatorComponent {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.indicatorButton = null;
|
|
9
|
+
this.scrollState = new EventEmitter();
|
|
10
|
+
this.isOverflowing = signal(false);
|
|
11
|
+
this.isAtBottom = signal(false);
|
|
12
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
13
|
+
this.resizeObserver = null;
|
|
14
|
+
}
|
|
15
|
+
ngAfterViewInit() {
|
|
16
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
17
|
+
this.updateOverflowState();
|
|
18
|
+
this.updateScrollState();
|
|
19
|
+
this.cdr.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
this.resizeObserver.observe(this.contentWrapper.nativeElement);
|
|
22
|
+
}
|
|
23
|
+
ngOnDestroy() {
|
|
24
|
+
this.resizeObserver?.disconnect();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Manually scrolls the content-container to the bottom
|
|
28
|
+
*/
|
|
29
|
+
scrollToBottom() {
|
|
30
|
+
this.contentWrapper.nativeElement.scrollTop = this.contentWrapper.nativeElement.scrollHeight;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* If the user scrolled all the way to the end of the container,
|
|
34
|
+
* the indicator button can be hidden
|
|
35
|
+
*/
|
|
36
|
+
onScroll() {
|
|
37
|
+
this.updateScrollState();
|
|
38
|
+
}
|
|
39
|
+
updateOverflowState() {
|
|
40
|
+
const element = this.contentWrapper.nativeElement;
|
|
41
|
+
const maxScroll = element.scrollHeight - element.offsetHeight;
|
|
42
|
+
this.isOverflowing.set(element.offsetHeight < element.scrollHeight && element.scrollTop < maxScroll);
|
|
43
|
+
}
|
|
44
|
+
updateScrollState() {
|
|
45
|
+
const element = this.contentWrapper.nativeElement;
|
|
46
|
+
const maxScroll = element.scrollHeight - element.offsetHeight;
|
|
47
|
+
this.isAtBottom.set(element.scrollTop + 1 >= maxScroll);
|
|
48
|
+
this.scrollState.emit(Math.round((100 / maxScroll) * (element.scrollTop + 1)));
|
|
49
|
+
}
|
|
50
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: ScrollViewWithIndicatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
51
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.9", type: ScrollViewWithIndicatorComponent, isStandalone: true, selector: "ng-scroll-view-with-indicator", inputs: { indicatorButton: "indicatorButton" }, outputs: { scrollState: "scrollState" }, viewQueries: [{ propertyName: "contentWrapper", first: true, predicate: ["contentWrapper"], descendants: true }], ngImport: i0, template: "<div class=\"content-wrapper\" #contentWrapper (scroll)=\"onScroll()\">\n <ng-content></ng-content>\n</div>\n\n<div class=\"scroll-indicator\" *ngIf=\"isOverflowing() && !isAtBottom()\">\n <ng-container *ngIf=\"indicatorButton; else defaultButton\" [ngTemplateOutlet]=\"indicatorButton\"></ng-container>\n\n <ng-template #defaultButton>\n <ng-scroll-view-default-indicator-button (buttonClicked)=\"scrollToBottom()\">\n </ng-scroll-view-default-indicator-button>\n </ng-template>\n</div>\n", styles: [":host{height:100%;max-height:100%;position:relative;min-height:0;display:flex}.content-wrapper{flex:1;max-height:100%;min-height:0;overflow-y:auto;box-sizing:border-box}.scroll-indicator{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: DefaultIndicatorButtonComponent, selector: "ng-scroll-view-default-indicator-button", outputs: ["buttonClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
52
|
+
}
|
|
53
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: ScrollViewWithIndicatorComponent, decorators: [{
|
|
54
|
+
type: Component,
|
|
55
|
+
args: [{ selector: 'ng-scroll-view-with-indicator', imports: [CommonModule, DefaultIndicatorButtonComponent], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"content-wrapper\" #contentWrapper (scroll)=\"onScroll()\">\n <ng-content></ng-content>\n</div>\n\n<div class=\"scroll-indicator\" *ngIf=\"isOverflowing() && !isAtBottom()\">\n <ng-container *ngIf=\"indicatorButton; else defaultButton\" [ngTemplateOutlet]=\"indicatorButton\"></ng-container>\n\n <ng-template #defaultButton>\n <ng-scroll-view-default-indicator-button (buttonClicked)=\"scrollToBottom()\">\n </ng-scroll-view-default-indicator-button>\n </ng-template>\n</div>\n", styles: [":host{height:100%;max-height:100%;position:relative;min-height:0;display:flex}.content-wrapper{flex:1;max-height:100%;min-height:0;overflow-y:auto;box-sizing:border-box}.scroll-indicator{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:center}\n"] }]
|
|
56
|
+
}], propDecorators: { contentWrapper: [{
|
|
57
|
+
type: ViewChild,
|
|
58
|
+
args: ['contentWrapper']
|
|
59
|
+
}], indicatorButton: [{
|
|
60
|
+
type: Input,
|
|
61
|
+
args: [{ required: true }]
|
|
62
|
+
}], scrollState: [{
|
|
63
|
+
type: Output
|
|
64
|
+
}] } });
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsLXZpZXctd2l0aC1pbmRpY2F0b3IuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9hbmd1bGFyLW92ZXJmbG93LWluZGljYXRvci9zcmMvbGliL3Njcm9sbC12aWV3LXdpdGgtaW5kaWNhdG9yL3Njcm9sbC12aWV3LXdpdGgtaW5kaWNhdG9yLmNvbXBvbmVudC50cyIsIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvYW5ndWxhci1vdmVyZmxvdy1pbmRpY2F0b3Ivc3JjL2xpYi9zY3JvbGwtdmlldy13aXRoLWluZGljYXRvci9zY3JvbGwtdmlldy13aXRoLWluZGljYXRvci5jb21wb25lbnQuaHRtbCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBRUwsdUJBQXVCLEVBQ3ZCLGlCQUFpQixFQUNqQixTQUFTLEVBQ1QsVUFBVSxFQUNWLFlBQVksRUFDWixNQUFNLEVBQ04sS0FBSyxFQUVMLE1BQU0sRUFDTixNQUFNLEVBRU4sU0FBUyxFQUNWLE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUMvQyxPQUFPLEVBQUUsK0JB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Component, ChangeDetectionStrategy, Output, signal, ChangeDetectorRef, inject, ViewChild, Input } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
|
|
6
|
+
class DefaultIndicatorButtonComponent {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.buttonClicked = new EventEmitter();
|
|
9
|
+
}
|
|
10
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultIndicatorButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
11
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.9", type: DefaultIndicatorButtonComponent, isStandalone: true, selector: "ng-scroll-view-default-indicator-button", outputs: { buttonClicked: "buttonClicked" }, ngImport: i0, template: `
|
|
12
|
+
<button class="default-button" (click)="buttonClicked.emit()">
|
|
13
|
+
<span>There is more content</span>
|
|
14
|
+
</button>
|
|
15
|
+
`, isInline: true, styles: ["button{border:none;font-size:.8rem;font-weight:500;padding:.4rem .6rem;background-color:#444;color:#fff;border-radius:1rem;margin-bottom:.4rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
16
|
+
}
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: DefaultIndicatorButtonComponent, decorators: [{
|
|
18
|
+
type: Component,
|
|
19
|
+
args: [{ selector: 'ng-scroll-view-default-indicator-button', template: `
|
|
20
|
+
<button class="default-button" (click)="buttonClicked.emit()">
|
|
21
|
+
<span>There is more content</span>
|
|
22
|
+
</button>
|
|
23
|
+
`, standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["button{border:none;font-size:.8rem;font-weight:500;padding:.4rem .6rem;background-color:#444;color:#fff;border-radius:1rem;margin-bottom:.4rem}\n"] }]
|
|
24
|
+
}], propDecorators: { buttonClicked: [{
|
|
25
|
+
type: Output
|
|
26
|
+
}] } });
|
|
27
|
+
|
|
28
|
+
class ScrollViewWithIndicatorComponent {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.indicatorButton = null;
|
|
31
|
+
this.scrollState = new EventEmitter();
|
|
32
|
+
this.isOverflowing = signal(false);
|
|
33
|
+
this.isAtBottom = signal(false);
|
|
34
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
35
|
+
this.resizeObserver = null;
|
|
36
|
+
}
|
|
37
|
+
ngAfterViewInit() {
|
|
38
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
39
|
+
this.updateOverflowState();
|
|
40
|
+
this.updateScrollState();
|
|
41
|
+
this.cdr.detectChanges();
|
|
42
|
+
});
|
|
43
|
+
this.resizeObserver.observe(this.contentWrapper.nativeElement);
|
|
44
|
+
}
|
|
45
|
+
ngOnDestroy() {
|
|
46
|
+
this.resizeObserver?.disconnect();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Manually scrolls the content-container to the bottom
|
|
50
|
+
*/
|
|
51
|
+
scrollToBottom() {
|
|
52
|
+
this.contentWrapper.nativeElement.scrollTop = this.contentWrapper.nativeElement.scrollHeight;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* If the user scrolled all the way to the end of the container,
|
|
56
|
+
* the indicator button can be hidden
|
|
57
|
+
*/
|
|
58
|
+
onScroll() {
|
|
59
|
+
this.updateScrollState();
|
|
60
|
+
}
|
|
61
|
+
updateOverflowState() {
|
|
62
|
+
const element = this.contentWrapper.nativeElement;
|
|
63
|
+
const maxScroll = element.scrollHeight - element.offsetHeight;
|
|
64
|
+
this.isOverflowing.set(element.offsetHeight < element.scrollHeight && element.scrollTop < maxScroll);
|
|
65
|
+
}
|
|
66
|
+
updateScrollState() {
|
|
67
|
+
const element = this.contentWrapper.nativeElement;
|
|
68
|
+
const maxScroll = element.scrollHeight - element.offsetHeight;
|
|
69
|
+
this.isAtBottom.set(element.scrollTop + 1 >= maxScroll);
|
|
70
|
+
this.scrollState.emit(Math.round((100 / maxScroll) * (element.scrollTop + 1)));
|
|
71
|
+
}
|
|
72
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: ScrollViewWithIndicatorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
73
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.9", type: ScrollViewWithIndicatorComponent, isStandalone: true, selector: "ng-scroll-view-with-indicator", inputs: { indicatorButton: "indicatorButton" }, outputs: { scrollState: "scrollState" }, viewQueries: [{ propertyName: "contentWrapper", first: true, predicate: ["contentWrapper"], descendants: true }], ngImport: i0, template: "<div class=\"content-wrapper\" #contentWrapper (scroll)=\"onScroll()\">\n <ng-content></ng-content>\n</div>\n\n<div class=\"scroll-indicator\" *ngIf=\"isOverflowing() && !isAtBottom()\">\n <ng-container *ngIf=\"indicatorButton; else defaultButton\" [ngTemplateOutlet]=\"indicatorButton\"></ng-container>\n\n <ng-template #defaultButton>\n <ng-scroll-view-default-indicator-button (buttonClicked)=\"scrollToBottom()\">\n </ng-scroll-view-default-indicator-button>\n </ng-template>\n</div>\n", styles: [":host{height:100%;max-height:100%;position:relative;min-height:0;display:flex}.content-wrapper{flex:1;max-height:100%;min-height:0;overflow-y:auto;box-sizing:border-box}.scroll-indicator{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: DefaultIndicatorButtonComponent, selector: "ng-scroll-view-default-indicator-button", outputs: ["buttonClicked"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
74
|
+
}
|
|
75
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.9", ngImport: i0, type: ScrollViewWithIndicatorComponent, decorators: [{
|
|
76
|
+
type: Component,
|
|
77
|
+
args: [{ selector: 'ng-scroll-view-with-indicator', imports: [CommonModule, DefaultIndicatorButtonComponent], standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"content-wrapper\" #contentWrapper (scroll)=\"onScroll()\">\n <ng-content></ng-content>\n</div>\n\n<div class=\"scroll-indicator\" *ngIf=\"isOverflowing() && !isAtBottom()\">\n <ng-container *ngIf=\"indicatorButton; else defaultButton\" [ngTemplateOutlet]=\"indicatorButton\"></ng-container>\n\n <ng-template #defaultButton>\n <ng-scroll-view-default-indicator-button (buttonClicked)=\"scrollToBottom()\">\n </ng-scroll-view-default-indicator-button>\n </ng-template>\n</div>\n", styles: [":host{height:100%;max-height:100%;position:relative;min-height:0;display:flex}.content-wrapper{flex:1;max-height:100%;min-height:0;overflow-y:auto;box-sizing:border-box}.scroll-indicator{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:center}\n"] }]
|
|
78
|
+
}], propDecorators: { contentWrapper: [{
|
|
79
|
+
type: ViewChild,
|
|
80
|
+
args: ['contentWrapper']
|
|
81
|
+
}], indicatorButton: [{
|
|
82
|
+
type: Input,
|
|
83
|
+
args: [{ required: true }]
|
|
84
|
+
}], scrollState: [{
|
|
85
|
+
type: Output
|
|
86
|
+
}] } });
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Generated bundle index. Do not edit.
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
export { ScrollViewWithIndicatorComponent };
|
|
93
|
+
//# sourceMappingURL=angular-overflow-indicator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-overflow-indicator.mjs","sources":["../../../../libs/angular-overflow-indicator/src/lib/default-indicator-button/default-indicator-button.component.ts","../../../../libs/angular-overflow-indicator/src/lib/scroll-view-with-indicator/scroll-view-with-indicator.component.ts","../../../../libs/angular-overflow-indicator/src/lib/scroll-view-with-indicator/scroll-view-with-indicator.component.html","../../../../libs/angular-overflow-indicator/src/angular-overflow-indicator.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core';\n\n@Component({\n selector: 'ng-scroll-view-default-indicator-button',\n template: `\n <button class=\"default-button\" (click)=\"buttonClicked.emit()\">\n <span>There is more content</span>\n </button>\n `,\n styles: `\n button {\n border: none;\n font-size: 0.8rem;\n font-weight: 500;\n padding: 0.4rem 0.6rem;\n background-color: #444444;\n color: #ffffff;\n border-radius: 1rem;\n margin-bottom: 0.4rem;\n }\n `,\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class DefaultIndicatorButtonComponent {\n @Output() buttonClicked = new EventEmitter();\n}\n","import {\n AfterViewInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n EventEmitter,\n inject,\n Input,\n OnDestroy,\n Output,\n signal,\n TemplateRef,\n ViewChild\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { DefaultIndicatorButtonComponent } from '../default-indicator-button';\n\n@Component({\n selector: 'ng-scroll-view-with-indicator',\n templateUrl: './scroll-view-with-indicator.component.html',\n styleUrls: ['./scroll-view-with-indicator.component.scss'],\n imports: [CommonModule, DefaultIndicatorButtonComponent],\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class ScrollViewWithIndicatorComponent implements AfterViewInit, OnDestroy {\n @ViewChild('contentWrapper') contentWrapper!: ElementRef<HTMLDivElement>;\n @Input({ required: true }) indicatorButton: TemplateRef<unknown> | null = null;\n @Output() scrollState = new EventEmitter<number>();\n\n readonly isOverflowing = signal(false);\n readonly isAtBottom = signal(false);\n\n private readonly cdr = inject(ChangeDetectorRef);\n private resizeObserver: ResizeObserver | null = null;\n\n ngAfterViewInit(): void {\n this.resizeObserver = new ResizeObserver(() => {\n this.updateOverflowState();\n this.updateScrollState();\n this.cdr.detectChanges();\n });\n\n this.resizeObserver.observe(this.contentWrapper.nativeElement);\n }\n\n ngOnDestroy(): void {\n this.resizeObserver?.disconnect();\n }\n\n /**\n * Manually scrolls the content-container to the bottom\n */\n scrollToBottom(): void {\n this.contentWrapper.nativeElement.scrollTop = this.contentWrapper.nativeElement.scrollHeight;\n }\n\n /**\n * If the user scrolled all the way to the end of the container,\n * the indicator button can be hidden\n */\n onScroll(): void {\n this.updateScrollState();\n }\n\n private updateOverflowState(): void {\n const element = this.contentWrapper.nativeElement;\n const maxScroll = element.scrollHeight - element.offsetHeight;\n this.isOverflowing.set(element.offsetHeight < element.scrollHeight && element.scrollTop < maxScroll);\n }\n\n private updateScrollState(): void {\n const element = this.contentWrapper.nativeElement;\n const maxScroll = element.scrollHeight - element.offsetHeight;\n this.isAtBottom.set(element.scrollTop + 1 >= maxScroll);\n this.scrollState.emit(Math.round((100 / maxScroll) * (element.scrollTop + 1)));\n }\n}\n","<div class=\"content-wrapper\" #contentWrapper (scroll)=\"onScroll()\">\n <ng-content></ng-content>\n</div>\n\n<div class=\"scroll-indicator\" *ngIf=\"isOverflowing() && !isAtBottom()\">\n <ng-container *ngIf=\"indicatorButton; else defaultButton\" [ngTemplateOutlet]=\"indicatorButton\"></ng-container>\n\n <ng-template #defaultButton>\n <ng-scroll-view-default-indicator-button (buttonClicked)=\"scrollToBottom()\">\n </ng-scroll-view-default-indicator-button>\n </ng-template>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;MAwBa,+BAA+B,CAAA;AAtB5C,IAAA,WAAA,GAAA;AAuBY,QAAA,IAAA,CAAA,aAAa,GAAG,IAAI,YAAY,EAAE,CAAC;AAC9C,KAAA;8GAFY,+BAA+B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA,EAAA;AAA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gBAAgB,CAAA;gBACA,eAAe,EAAA,CAAA;sBAAzC,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;gBACf,WAAW,EAAA,CAAA;sBAApB,MAAM;;;AE7BT;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/scroll-view-with-indicator';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class DefaultIndicatorButtonComponent {
|
|
4
|
+
buttonClicked: EventEmitter<any>;
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DefaultIndicatorButtonComponent, never>;
|
|
6
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DefaultIndicatorButtonComponent, "ng-scroll-view-default-indicator-button", never, {}, { "buttonClicked": "buttonClicked"; }, never, never, true, never>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DefaultIndicatorButtonComponent } from './default-indicator-button.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ScrollViewWithIndicatorComponent } from './scroll-view-with-indicator.component';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AfterViewInit, ElementRef, EventEmitter, OnDestroy, TemplateRef } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class ScrollViewWithIndicatorComponent implements AfterViewInit, OnDestroy {
|
|
4
|
+
contentWrapper: ElementRef<HTMLDivElement>;
|
|
5
|
+
indicatorButton: TemplateRef<unknown> | null;
|
|
6
|
+
scrollState: EventEmitter<number>;
|
|
7
|
+
readonly isOverflowing: import("@angular/core").WritableSignal<boolean>;
|
|
8
|
+
readonly isAtBottom: import("@angular/core").WritableSignal<boolean>;
|
|
9
|
+
private readonly cdr;
|
|
10
|
+
private resizeObserver;
|
|
11
|
+
ngAfterViewInit(): void;
|
|
12
|
+
ngOnDestroy(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Manually scrolls the content-container to the bottom
|
|
15
|
+
*/
|
|
16
|
+
scrollToBottom(): void;
|
|
17
|
+
/**
|
|
18
|
+
* If the user scrolled all the way to the end of the container,
|
|
19
|
+
* the indicator button can be hidden
|
|
20
|
+
*/
|
|
21
|
+
onScroll(): void;
|
|
22
|
+
private updateOverflowState;
|
|
23
|
+
private updateScrollState;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScrollViewWithIndicatorComponent, never>;
|
|
25
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScrollViewWithIndicatorComponent, "ng-scroll-view-with-indicator", never, { "indicatorButton": { "alias": "indicatorButton"; "required": true; }; }, { "scrollState": "scrollState"; }, never, ["*"], true, never>;
|
|
26
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "angular-overflow-indicator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A simple and performant component that displays a given button if the content of the component overflows",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/hansireit/angular-lib",
|
|
9
|
+
"directory": "libs/angular-overflow-indicator"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@angular/common": "^17.0.0",
|
|
13
|
+
"@angular/core": "^17.0.0"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"tslib": "^2.3.0"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"keywords": [
|
|
20
|
+
"angular",
|
|
21
|
+
"overflow",
|
|
22
|
+
"indicator",
|
|
23
|
+
"button",
|
|
24
|
+
"scroll"
|
|
25
|
+
],
|
|
26
|
+
"module": "fesm2022/angular-overflow-indicator.mjs",
|
|
27
|
+
"typings": "index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": {
|
|
30
|
+
"default": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./index.d.ts",
|
|
34
|
+
"esm2022": "./esm2022/angular-overflow-indicator.mjs",
|
|
35
|
+
"esm": "./esm2022/angular-overflow-indicator.mjs",
|
|
36
|
+
"default": "./fesm2022/angular-overflow-indicator.mjs"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|