File tree 5 files changed +25
-14
lines changed
5 files changed +25
-14
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @alauda/ui " : patch
3
+ ---
4
+
5
+ feat: backtop support custom position
Original file line number Diff line number Diff line change 1
1
< div
2
2
class ="aui-back-top "
3
- [class.show] ="isDisplayed$ | async "
3
+ [style.display] ="display$ | async "
4
+ [style.position] ="'fixed' "
5
+ [style] ="position "
4
6
>
5
7
< button
6
8
aui-button ="text "
Original file line number Diff line number Diff line change 4
4
$block : ' aui-back-top' ;
5
5
6
6
.#{$block } {
7
- position : fixed ;
8
- right : 12px ;
9
- bottom : 12px ;
10
7
@include flex-center ;
11
8
12
9
height : use-var (inline-height-m );
13
10
width : use-var (inline-height-m );
14
11
border-radius : use-var (border-radius-m );
15
12
overflow : hidden ;
16
- visibility : hidden ;
17
13
cursor : pointer ;
18
14
@include popper-shadow ;
19
15
20
16
background-color : use-rgb (n-10 );
21
-
22
- & .show {
23
- visibility : visible ;
24
- }
25
17
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
map ,
17
17
switchMap ,
18
18
throttleTime ,
19
+ startWith ,
19
20
} from 'rxjs' ;
20
21
21
22
type TargetType = Element | Window | string ;
@@ -39,6 +40,14 @@ export class BackTopComponent {
39
40
return this . _visibilityHeight ;
40
41
}
41
42
43
+ @Input ( )
44
+ position : {
45
+ left ?: string ;
46
+ right ?: string ;
47
+ top ?: string ;
48
+ bottom ?: string ;
49
+ } = { right : '12px' , bottom : '12px' } ;
50
+
42
51
@Input ( )
43
52
set target ( val : TargetType ) {
44
53
this . _target = val ;
@@ -63,7 +72,7 @@ export class BackTopComponent {
63
72
64
73
constructor ( @Optional ( ) private readonly cdkScrollable : CdkScrollable ) { }
65
74
66
- isDisplayed $ = combineLatest ( [
75
+ display $ = combineLatest ( [
67
76
this . target$$ . asObservable ( ) . pipe (
68
77
map ( target => this . getTarget ( target ) ) ,
69
78
switchMap ( target =>
@@ -77,6 +86,8 @@ export class BackTopComponent {
77
86
this . visibilityHeight$$ ,
78
87
] ) . pipe (
79
88
map ( ( [ scrollTop , visibilityHeight ] ) => scrollTop >= visibilityHeight ) ,
89
+ map ( visible => ( visible ? 'flex' : 'none' ) ) ,
90
+ startWith ( 'none' ) ,
80
91
distinctUntilChanged ( ) ,
81
92
) ;
82
93
Original file line number Diff line number Diff line change @@ -41,10 +41,11 @@ import * as useSelector from './use-selector.stories';
41
41
42
42
## Backtop Inputs
43
43
44
- | 名称 | 类型 | 默认值 | 描述 |
45
- | ---------------- | --------------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------- |
46
- | visibilityHeight | number | 400 | 目标容器滚动到多高的距离,展示 backtop 按钮 |
47
- | target | Element \| Window \| string | - | 指定目标容器,可以指定 ElementRef,selector 来选择目标组件,不指定时优先选择外部的 cdkScrollable 组件,若没有则选择 window |
44
+ | 名称 | 类型 | 默认值 | 描述 |
45
+ | ---------------- | ------------------------------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
46
+ | visibilityHeight | number | 400 | 目标容器滚动到多高的距离,展示 backtop 按钮 |
47
+ | position | \{ left?: string; right?: string; top?: string; bottom?: string; \} | \{ right: '12px', bottom: '12px' \} | 设置按钮在浏览器窗口中的位置 |
48
+ | target | Element \| Window \| string | - | 指定目标容器,可以指定 ElementRef,selector 来选择目标组件,不指定时优先选择外部的 cdkScrollable 组件,若没有则选择 window |
48
49
49
50
## Backtop Outputs
50
51
You can’t perform that action at this time.
0 commit comments