Skip to content

Commit

Permalink
Merge pull request #328 from MurhafSousli/v7.4.2
Browse files Browse the repository at this point in the history
V7.4.2
  • Loading branch information
MurhafSousli authored Dec 20, 2020
2 parents c9ecfa4 + 71affcd commit 67ad816
Show file tree
Hide file tree
Showing 32 changed files with 167 additions and 138 deletions.
16 changes: 8 additions & 8 deletions projects/ngx-scrollbar-demo/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<div class="page-wrapper">
<div class="wide-container">
<app-example-x *ngIf="largeScreen | async"></app-example-x>
<app-example-x *ngIf="largeScreen$ | async"></app-example-x>
</div>

<div class="container">
Expand All @@ -19,14 +19,16 @@ <h2 class="mat-typography">Examples</h2>

<app-example2></app-example2>

<app-example-scrollto-element></app-example-scrollto-element>

<app-example3></app-example3>

<app-example4></app-example4>

<app-example5></app-example5>

<h2 class="mat-typography">Smooth scroll example</h2>

<app-example-scrollto-element></app-example-scrollto-element>

<h2 class="mat-typography">Integrating with other libraries</h2>

<app-example-infinite-scroll></app-example-infinite-scroll>
Expand All @@ -46,8 +48,6 @@ <h2 class="mat-typography">Integrating with other libraries</h2>

</ng-scrollbar>

<!--<div class="go-top">-->
<!-- <button *ngIf="showGoToTopButton" mat-fab color="accent" (click)="scrollable.scrollToTop(800)">-->
<!-- <mat-icon>arrow_upward</mat-icon>-->
<!-- </button>-->
<!--</div>-->
<button *ngIf="scrollToIcon$ | async as icon" mat-fab (click)="scrollToEdge(icon)">
<mat-icon>{{ icon === 'top' ? 'keyboard_arrow_up' : 'keyboard_arrow_down' }}</mat-icon>
</button>
6 changes: 6 additions & 0 deletions projects/ngx-scrollbar-demo/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ ng-scrollbar {
bottom: 2em;
right: 2em;
}

.mat-fab {
position: fixed;
bottom: 2em;
left: 2em;
}
39 changes: 32 additions & 7 deletions projects/ngx-scrollbar-demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,45 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ChangeDetectionStrategy, Component, AfterViewInit, ViewChild } from '@angular/core';
import { BreakpointObserver, Breakpoints, BreakpointState } from '@angular/cdk/layout';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { NgScrollbar } from 'ngx-scrollbar';
import { BehaviorSubject, Observable } from 'rxjs';
import { auditTime, map, tap } from 'rxjs/operators';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent {
showGoToTopButton = false;
largeScreen: Observable<boolean>;
export class AppComponent implements AfterViewInit {

@ViewChild(NgScrollbar) scrollable: NgScrollbar;

largeScreen$: Observable<boolean>;

scrollToIcon$ = new BehaviorSubject<string>('bottom');

constructor(breakpointObserver: BreakpointObserver) {
this.largeScreen = breakpointObserver.observe(Breakpoints.HandsetPortrait).pipe(map((state: BreakpointState) => !state.matches));
this.largeScreen$ = breakpointObserver.observe(Breakpoints.HandsetPortrait).pipe(map((state: BreakpointState) => !state.matches));
}

ngAfterViewInit() {
this.scrollable.verticalScrolled.pipe(
auditTime(200),
tap(() => {
const center = this.scrollable.viewport.clientHeight / 2;
const scrollHeight = this.scrollable.viewport.scrollHeight;
const scrollTop = this.scrollable.viewport.scrollTop;
this.scrollToIcon$.next(scrollTop + center > scrollHeight / 2 ? 'top' : 'bottom');
})
).subscribe();
}

scrollToEdge(icon: string) {
if (icon === 'top') {
this.scrollable.scrollTo({ top: 0 });
} else {
this.scrollable.scrollTo({ bottom: 0 });
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="example">
<mat-card class="example mat-elevation-z16">
<mat-card-header>
<mat-card-title>
Ngx-infinite-scroll Example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card>
<mat-card class="mat-elevation-z16">
<mat-card-header>
<mat-card-title>
Nested CDK Virtual Scroll Example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
<mat-card class="example">
<mat-card class="example mat-elevation-z16">
<mat-card-header>
<mat-card-title>
ScrollToElement
</mat-card-title>
</mat-card-header>
<mat-card-content>
<div class="scrolltoExample">
<ng-scrollbar appearance="compact">
<ul>
<li class="example-item"
*ngFor="let item of [].constructor(20); index as i"
(click)="scrollToItem(itemEl)" #itemEl>
item {{i}}
</li>
</ul>
</ng-scrollbar>
<div class="center-pointer">
<mat-icon>play_arrow</mat-icon>
</div>

<div class="scroll-to-example">
<ng-scrollbar pointerEventsMethod="scrollbar"
appearance="compact"
autoHeightDisabled="true">
<ul>
<li class="example-item"
*ngFor="let item of [].constructor(20); index as i"
#itemEl
(click)="scrollToItem(itemEl)">
item {{i}}
</li>
</ul>
</ng-scrollbar>
</div>
</mat-card-content>
</mat-card>
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
.example {
background-color: var(--color-virtual-scroll-example);
color: white;
}

.scrolltoExample {
.scroll-to-example {
background-color: #f3f3f3;
border-radius: 3px;
overflow: hidden;
Expand All @@ -12,10 +7,10 @@
.mat-list-base {
padding-top: 0;
}

ng-scrollbar {
--scrollbar-track-color: rgba(0, 0, 0, 0.05);
--scrollbar-thumb-color: var(--color-virtual-scroll-example);
//--scrollbar-size: 8px;
--scrollbar-thumb-color: var(--color-primary);
--scrollbar-size: 12px;
--scrollbar-padding: 6px;
--scrollbar-border-radius: 8px;
Expand All @@ -39,9 +34,24 @@
background: #ecf8ff;
}

&:hover{
&:hover {
background: #d2d2ff;
}
}
}

.mat-card-content {
position: relative;
}

.center-pointer {
width: 20px;
height: 20px;
position: absolute;
left: -20px;
top: calc(50% - 10px);

.mat-icon {
color: var(--color-accent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ export class ExampleScrolltoElementComponent {
@ViewChild(NgScrollbar, { static: true }) scrollbar: NgScrollbar;

scrollToItem(el: HTMLElement) {
this.scrollbar.scrollToElement(el);
this.scrollbar.scrollToElement(el, { top: -125 });
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="example">
<mat-card class="example mat-elevation-z16">
<mat-card-header>
<mat-card-title>
CDK Virtual Scroll Example
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="example exampleX">
<mat-card>
<mat-card class="mat-elevation-z16">
<mat-card-header>
<mat-card-title>Lab</mat-card-title>
<span style="flex: 1"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ $scrollable-height: 268px;
}

.mat-card {
background-color: var(--color-examplex-accent);
color: white;
font-weight: 300;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
.display-function {
font-family: monospace;
font-size: 14px;
background-color: var(--color-examplex-accent);
background-color: var(--color-primary);
border-radius: 4px;
padding: 0.3em 0.5em;
color: white;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="example">
<mat-card class="example mat-elevation-z16">
<mat-card-content>
<div class="example2">
<div class="sample">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ng-scrollbar {
}

.example {
background-color: var(--color-example-2);
background-attachment: fixed;
background-size: cover;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="example example3">
<mat-card class="example example3 mat-elevation-z16">
<mat-card-content>
<div class="sample-wrapper">
<ng-scrollbar class="sample"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="example example4">
<mat-card class="example example4 mat-elevation-z16">
<mat-card-content>
<div class="sample-wrapper">
<ng-scrollbar class="sample"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-card class="example example5">
<mat-card class="example example5 mat-elevation-z16">
<mat-card-content>
<div class="sample">
<div class="editor">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.example5 {
color: #686c6e;
background-color: var(--color-example-5);

ng-scrollbar {
--scrollbar-track-color: #f3f4f8;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
<h3>Author</h3>
<div class="author">
<div class="author-photo">
<img src="https://www.gravatar.com/avatar/7261d414a78ed3118aa86a5e0c8a93d1?s=328&d=identicon&r=PG" alt="author-photo">
</div>
<div class="author-info">
<p>Murhaf Sousli</p>
<p><span>Software Engineer</span></p>
<div class="author-twitter">
<a href="https://twitter.com/murhafsousli?ref_src=twsrc%5Etfw" aria-label="Follow @murhafsousli on Twitter">
<i class="fa fa-twitter"></i>
<span>twitter.com/murhafsousli</span>
</a>
</div>
<div class="author-twitter">
<a class="github-button" href="https://github.com/murhafsousli" aria-label="Follow @murhafsousli on GitHub">
<i class="fa fa-github"></i>
<span>github.com/murhafsousli</span>
</a>
</div>
</div>
<p>Made with ❤️ by Murhaf Sousli</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,6 @@
font-weight: 300;
}

.author-photo {
border-radius: 50%;
overflow: hidden;
width: 120px;
height: 120px;

img {
display: block;
width: 100%;
height: 100%;
}
}

.author-info {
margin-left: 1em;
display: flex;
flex-direction: column;
justify-content: center;
}

.author-twitter, .author-github {
display: flex;
flex-direction: column;
justify-content: center;
}

h3 {
text-align: center;
color: var(--color-accent);
margin-bottom: 2em;
}

p {
margin-top: 0;
margin-bottom: 5px;
}

i {
margin-right: 5px;
}

span {
font-size: 14px;
margin-bottom: 5px;
font-size: 24px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
<div class="container">
<app-author></app-author>
</div>

<svg class="wave-bg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
<path fill="var(--color-app-background)"
d="M0,128L60,138.7C120,149,240,171,360,160C480,149,600,107,720,122.7C840,139,960,213,1080,240C1200,267,1320,245,1380,234.7L1440,224L1440,320L1380,320C1320,320,1200,320,1080,320C960,320,840,320,720,320C600,320,480,320,360,320C240,320,120,320,60,320L0,320Z"></path>
</svg>

</footer>
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.footer {
color: white;
padding: 1em 1em 4em;
margin: 2em auto 0;
margin: 0 auto;
position: relative;

p {
margin-bottom: 0;
Expand All @@ -16,3 +17,10 @@
display: block;
}
}

.wave-bg {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<div class="header">
<!-- <svg class="wave-bg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">-->
<!-- <path fill="#0099ff" fill-opacity="1" d="M0,256L48,229.3C96,203,192,149,288,154.7C384,160,480,224,576,218.7C672,213,768,139,864,128C960,117,1056,171,1152,197.3C1248,224,1344,224,1392,224L1440,224L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path>-->
<!-- </svg>-->

<svg class="wave-bg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
<path fill="var(--color-app-background)"
d="M0,288L48,266.7C96,245,192,203,288,202.7C384,203,480,245,576,250.7C672,256,768,224,864,224C960,224,1056,256,1152,261.3C1248,267,1344,245,1392,234.7L1440,224L1440,0L1392,0C1344,0,1248,0,1152,0C1056,0,960,0,864,0C768,0,672,0,576,0C480,0,384,0,288,0C192,0,96,0,48,0L0,0Z"></path>
</svg>

<div class="container" [style.maxWidth.px]="900">
<app-logo></app-logo>
Expand Down
Loading

0 comments on commit 67ad816

Please sign in to comment.