@@ -40,61 +40,43 @@ export class AppBottomSheet {
4040 }
4141
4242 private initWindowResize ( ) {
43- if ( window ) {
44- window . addEventListener ( 'resize' , debounce ( this . onWindowResize ) ) ;
45- }
43+ window ?. addEventListener ( 'resize' , debounce ( this . onWindowResize ) ) ;
4644 }
4745
4846 private removeWindowResize ( ) {
49- if ( window ) {
50- window . removeEventListener ( 'resize' , debounce ( this . onWindowResize ) ) ;
51- }
47+ window ?. removeEventListener ( 'resize' , debounce ( this . onWindowResize ) ) ;
5248 }
5349
5450 private onWindowResize = async ( ) => {
5551 await this . initSize ( ) ;
5652 } ;
5753
58- private initSize ( ) : Promise < void > {
59- return new Promise < void > ( ( resolve ) => {
60- this . bottomSheetTop = this . bottomSheetMinHeight ;
61- this . heightOffset = this . content . offsetHeight || this . el . offsetHeight ;
62- this . contentHeight = window . innerHeight || screen . height ;
63-
64- resolve ( ) ;
65- } ) ;
54+ private async initSize ( ) {
55+ this . bottomSheetTop = this . bottomSheetMinHeight ;
56+ this . heightOffset = this . content . offsetHeight || this . el . offsetHeight ;
57+ this . contentHeight = window . innerHeight || screen . height ;
6658 }
6759
68- private init ( ) : Promise < void > {
69- return new Promise < void > ( ( resolve ) => {
70- if ( ! this . container ) {
71- resolve ( ) ;
72- return ;
73- }
74-
75- this . container . addEventListener ( 'mousedown' , this . startEvent , { passive : false } ) ;
76- this . container . addEventListener ( 'touchstart' , this . startEvent , { passive : false } ) ;
77- document . addEventListener ( 'mouseup' , this . endEvent , { passive : false } ) ;
78- document . addEventListener ( 'touchend' , this . endEvent , { passive : false } ) ;
60+ private async init ( ) {
61+ if ( ! this . container ) {
62+ return ;
63+ }
7964
80- resolve ( ) ;
81- } ) ;
65+ this . container . addEventListener ( 'mousedown' , this . startEvent , { passive : false } ) ;
66+ this . container . addEventListener ( 'touchstart' , this . startEvent , { passive : false } ) ;
67+ document . addEventListener ( 'mouseup' , this . endEvent , { passive : false } ) ;
68+ document . addEventListener ( 'touchend' , this . endEvent , { passive : false } ) ;
8269 }
8370
84- private destroy ( ) : Promise < void > {
85- return new Promise < void > ( ( resolve ) => {
86- if ( ! this . container ) {
87- resolve ( ) ;
88- return ;
89- }
90-
91- this . container . removeEventListener ( 'mousedown' , this . startEvent , true ) ;
92- this . container . removeEventListener ( 'touchstart' , this . startEvent , true ) ;
93- document . removeEventListener ( 'mouseup' , this . endEvent , true ) ;
94- document . removeEventListener ( 'touchend' , this . endEvent , true ) ;
71+ private async destroy ( ) {
72+ if ( ! this . container ) {
73+ return ;
74+ }
9575
96- resolve ( ) ;
97- } ) ;
76+ this . container . removeEventListener ( 'mousedown' , this . startEvent , true ) ;
77+ this . container . removeEventListener ( 'touchstart' , this . startEvent , true ) ;
78+ document . removeEventListener ( 'mouseup' , this . endEvent , true ) ;
79+ document . removeEventListener ( 'touchend' , this . endEvent , true ) ;
9880 }
9981
10082 private startEvent = ( $event : MouseEvent | TouchEvent ) => {
@@ -138,6 +120,16 @@ export class AppBottomSheet {
138120 this . sheetChanged . emit ( this . bottomSheetTop === this . bottomSheetMinHeight ? 'close' : 'open' ) ;
139121 }
140122
123+ private toggle ( $event : UIEvent ) {
124+ $event . stopPropagation ( ) ;
125+
126+ this . bottomSheetTop = this . bottomSheetTop === this . bottomSheetMinHeight ? this . content . offsetHeight : this . bottomSheetMinHeight ;
127+
128+ this . startY = undefined ;
129+
130+ this . sheetChanged . emit ( this . bottomSheetTop === this . bottomSheetMinHeight ? 'close' : 'open' ) ;
131+ }
132+
141133 render ( ) {
142134 return (
143135 < Host
@@ -146,7 +138,9 @@ export class AppBottomSheet {
146138 '--contentheight' : `${ this . contentHeight } px` ,
147139 } } >
148140 < div class = "container" ref = { ( el ) => ( this . container = el ) } >
149- < div class = "sheet-indicator" > </ div >
141+ < button class = "sheet-indicator" onClick = { ( $event : UIEvent ) => this . toggle ( $event ) } >
142+ < div > </ div >
143+ </ button >
150144 < div class = "content" ref = { ( el ) => ( this . content = el ) } >
151145 < slot > </ slot >
152146 </ div >
0 commit comments