-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: scroll spy threshold is customizable (#578)
* scroll spy enhancement * added HTMLElement type
- Loading branch information
Showing
10 changed files
with
146 additions
and
25 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...rs/scroll-spy/examples/scroll-spy-custom-example/scroll-spy-custom-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="header-container"> | ||
<div class="header-item" *ngFor="let item of items" [ngClass]="{'selected': selectedSpy === item.id}"> | ||
<span class="icon"> | ||
<fd-icon [glyph]="'arrow-right'" [size]="'xs'"></fd-icon> | ||
</span> | ||
{{item.name}} | ||
</div> | ||
</div> | ||
|
||
<div class="list-container" fdScrollSpy [trackedTags]="['div']" [targetPercent]="0.5" (spyChange)="selectedSpy = $event.id"> | ||
<div class="item" *ngFor="let item of items" [id]="item.id">{{item.name}}</div> | ||
</div> | ||
|
||
<div class="middle-marker-container"> | ||
<div class="marker"></div> | ||
</div> |
57 changes: 57 additions & 0 deletions
57
...rs/scroll-spy/examples/scroll-spy-custom-example/scroll-spy-custom-example.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: row; | ||
height: 190px; | ||
position: relative; | ||
} | ||
|
||
.item { | ||
height: 40px; | ||
display: flex; | ||
align-items: center; | ||
|
||
&:last-child { | ||
height: 220px; | ||
align-items: flex-start; | ||
padding-top: 10px; | ||
} | ||
} | ||
|
||
.list-container { | ||
border: 1px dashed black; | ||
overflow: auto; | ||
flex-grow: 1; | ||
} | ||
|
||
.header-container { | ||
flex-direction: column; | ||
display: flex; | ||
width: 140px; | ||
.header-item { | ||
display: inline-block; | ||
} | ||
} | ||
|
||
.icon { | ||
left: -4px; | ||
opacity: 0; | ||
} | ||
|
||
.selected { | ||
font-weight: bold; | ||
.icon { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.middle-marker-container { | ||
position: absolute; | ||
top: 50%; | ||
right: 0; | ||
height: 0; | ||
width: calc(100% - 140px); | ||
.marker { | ||
height: 1px; | ||
border: 0.5px dashed black; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ners/scroll-spy/examples/scroll-spy-custom-example/scroll-spy-custom-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'fd-scroll-spy-custom-example', | ||
templateUrl: './scroll-spy-custom-example.component.html', | ||
styleUrls: ['./scroll-spy-custom-example.component.scss'] | ||
}) | ||
export class ScrollSpyCustomExampleComponent implements OnInit { | ||
|
||
selectedSpy = 'element-2'; | ||
items: any[] = []; | ||
|
||
ngOnInit() { | ||
this.generateItems(9); | ||
} | ||
|
||
generateItems(count: number): void { | ||
for (let i = 0; i < count; ++i) { | ||
this.items.push({name: 'Element ' + i, id: 'element-' + i}); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters