-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core):
Dialog
fix scrollbar width issues (#5488)
- Loading branch information
Showing
40 changed files
with
462 additions
and
60 deletions.
There are no files selected for viewing
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
3 changes: 1 addition & 2 deletions
3
projects/addon-mobile/components/pull-to-refresh/pull-to-refresh.service.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
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
3 changes: 1 addition & 2 deletions
3
projects/addon-mobile/components/sheet/directives/sheet-stop/sheet-stop.directive.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
3 changes: 2 additions & 1 deletion
3
projects/addon-mobile/directives/elastic-sticky/elastic-sticky.service.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from '@taiga-ui/cdk/components/alert-host'; | ||
export * from '@taiga-ui/cdk/components/dialog-host'; | ||
export * from '@taiga-ui/cdk/components/dropdown-host'; | ||
export * from '@taiga-ui/cdk/components/scroll-controls'; |
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,4 @@ | ||
export * from './scroll-controls.component'; | ||
export * from './scroll-controls.module'; | ||
export * from './scroll-ref.directive'; | ||
export * from './scrollbar.directive'; |
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,5 @@ | ||
{ | ||
"lib": { | ||
"entryFile": "index.ts" | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
projects/cdk/components/scroll-controls/scroll-controls.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,44 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
Inject, | ||
NgZone, | ||
} from '@angular/core'; | ||
import {ANIMATION_FRAME} from '@ng-web-apis/common'; | ||
import {tuiZoneOptimized} from '@taiga-ui/cdk/observables'; | ||
import {TUI_SCROLL_REF} from '@taiga-ui/cdk/tokens'; | ||
import {Observable} from 'rxjs'; | ||
import {distinctUntilChanged, map, startWith, throttleTime} from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'tui-scroll-controls', | ||
templateUrl: './scroll-controls.template.html', | ||
styleUrls: ['./scroll-controls.style.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiScrollControlsComponent { | ||
readonly refresh$ = this.animationFrame$.pipe( | ||
throttleTime(300), | ||
map(() => this.scrollbars), | ||
startWith([false, false]), | ||
distinctUntilChanged((a, b) => a[0] === b[0] && a[1] === b[1]), | ||
tuiZoneOptimized(this.zone), | ||
); | ||
|
||
constructor( | ||
@Inject(NgZone) private readonly zone: NgZone, | ||
@Inject(TUI_SCROLL_REF) private readonly scrollRef: ElementRef<HTMLElement>, | ||
@Inject(ANIMATION_FRAME) private readonly animationFrame$: Observable<number>, | ||
) {} | ||
|
||
private get scrollbars(): [boolean, boolean] { | ||
const {clientHeight, scrollHeight, clientWidth, scrollWidth} = | ||
this.scrollRef.nativeElement; | ||
|
||
return [ | ||
Math.ceil((clientHeight / scrollHeight) * 100) < 100, | ||
Math.ceil((clientWidth / scrollWidth) * 100) < 100, | ||
]; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
projects/cdk/components/scroll-controls/scroll-controls.module.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,17 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
|
||
import {TuiScrollControlsComponent} from './scroll-controls.component'; | ||
import {TuiScrollRefDirective} from './scroll-ref.directive'; | ||
import {TuiScrollbarDirective} from './scrollbar.directive'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
declarations: [ | ||
TuiScrollbarDirective, | ||
TuiScrollControlsComponent, | ||
TuiScrollRefDirective, | ||
], | ||
exports: [TuiScrollControlsComponent, TuiScrollRefDirective], | ||
}) | ||
export class TuiScrollControlsModule {} |
87 changes: 87 additions & 0 deletions
87
projects/cdk/components/scroll-controls/scroll-controls.style.less
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,87 @@ | ||
@scroll-width: 0.75rem; | ||
@scroll-width-large: 0.875rem; | ||
@scroll-min-size: 1.25rem; | ||
|
||
:host { | ||
position: sticky; | ||
top: 0; | ||
left: 0; | ||
z-index: 1; | ||
min-width: calc(100% - 1px); | ||
min-height: calc(100% - 1px); | ||
max-width: calc(100% - 1px); | ||
max-height: calc(100% - 1px); | ||
float: left; | ||
margin-inline-end: calc(-100% + 1px); | ||
pointer-events: none; | ||
} | ||
|
||
.t-bar { | ||
position: absolute; | ||
right: 0; | ||
bottom: 0; | ||
pointer-events: auto; | ||
animation: tuiFadeIn var(--tui-duration, 300ms) ease-in-out; | ||
|
||
&_vertical { | ||
top: 0; | ||
width: @scroll-width-large; | ||
} | ||
|
||
&_horizontal { | ||
left: 0; | ||
height: @scroll-width-large; | ||
} | ||
|
||
&_has-horizontal { | ||
bottom: @scroll-width - 0.25rem; | ||
} | ||
|
||
&_has-vertical { | ||
right: @scroll-width - 0.25rem; | ||
} | ||
} | ||
|
||
.t-thumb { | ||
position: absolute; | ||
border-radius: 6.25rem; | ||
border: 0.25rem solid transparent; | ||
cursor: pointer; | ||
pointer-events: auto; | ||
background: currentColor; | ||
background-clip: content-box; | ||
box-sizing: border-box; | ||
transition: all var(--tui-duration, 300ms) ease-in-out; | ||
transition-property: width, height, opacity; | ||
opacity: 0.2; | ||
|
||
&:hover { | ||
opacity: 0.24; | ||
} | ||
|
||
&:active { | ||
opacity: 0.48; | ||
} | ||
|
||
.t-bar_vertical & { | ||
right: 0; | ||
width: @scroll-width; | ||
min-height: @scroll-min-size; | ||
} | ||
|
||
.t-bar_vertical:hover &, | ||
.t-bar_vertical &:active { | ||
width: @scroll-width-large; | ||
} | ||
|
||
.t-bar_horizontal & { | ||
bottom: 0; | ||
height: @scroll-width; | ||
min-width: @scroll-min-size; | ||
} | ||
|
||
.t-bar_horizontal:hover &, | ||
.t-bar_horizontal &:active { | ||
height: @scroll-width-large; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
projects/cdk/components/scroll-controls/scroll-controls.template.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,22 @@ | ||
<ng-container *ngIf="refresh$ | async as bars"> | ||
<div | ||
*ngIf="bars[0]" | ||
class="t-bar t-bar_vertical" | ||
[class.t-bar_has-horizontal]="bars[1]" | ||
> | ||
<div | ||
tuiScrollbar="vertical" | ||
class="t-thumb" | ||
></div> | ||
</div> | ||
<div | ||
*ngIf="bars[1]" | ||
class="t-bar t-bar_horizontal" | ||
[class.t-bar_has-vertical]="bars[0]" | ||
> | ||
<div | ||
tuiScrollbar="horizontal" | ||
class="t-thumb" | ||
></div> | ||
</div> | ||
</ng-container> |
Oops, something went wrong.