Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e98f59

Browse files
committed
fix(sidebar): emit visible event on mobile layout change
1 parent13c3d32 commit7e98f59

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

‎projects/coreui-angular/src/lib/sidebar/sidebar/sidebar.component.ts‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { SidebarBackdropService } from '../sidebar-backdrop/sidebar-backdrop.ser
2222
@Component({
2323
selector:'c-sidebar',
2424
exportAs:'cSidebar',
25-
template:'<ng-content></ng-content>',
25+
template:'<ng-content></ng-content>'
2626
})
2727
exportclassSidebarComponentimplementsOnChanges,OnDestroy,OnInit{
2828

@@ -58,6 +58,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
5858
setnarrow(value:boolean){
5959
this._narrow=coerceBooleanProperty(value);
6060
}
61+
6162
getnarrow(){
6263
returnthis._narrow;
6364
}
@@ -70,6 +71,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
7071
setoverlaid(value:boolean){
7172
this._overlaid=coerceBooleanProperty(value);
7273
}
74+
7375
getoverlaid(){
7476
returnthis._overlaid;
7577
}
@@ -92,6 +94,7 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
9294
setunfoldable(value:boolean){
9395
this._unfoldable=coerceBooleanProperty(value);
9496
}
97+
9598
getunfoldable(){
9699
returnthis._unfoldable;
97100
}
@@ -101,9 +104,13 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
101104
*/
102105
@Input()
103106
setvisible(value:boolean){
104-
this._visible=coerceBooleanProperty(value);
105-
this.visibleChange.emit(this._visible);
107+
constvisible=coerceBooleanProperty(value);
108+
if(this._visible!==visible){
109+
this._visible=visible;
110+
this.visibleChange.emit(this._visible);
111+
}
106112
}
113+
107114
getvisible(){
108115
returnthis._visible;
109116
}
@@ -124,6 +131,8 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
124131
newState.unfoldable=!this.state.unfoldable;
125132
this.unfoldable=newState.unfoldable;
126133
}
134+
}else{
135+
this.visible=(newState.visible??this.visible)&&!this.overlaid;
127136
}
128137
this.state={
129138
...this.state,
@@ -155,12 +164,12 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
155164

156165
@HostBinding('class')
157166
getgetClasses():any{
158-
const{mobile, unfoldable, visible}=this.sidebarState;
167+
const{mobile, unfoldable, visible}=this.sidebarState;
159168
return{
160169
sidebar:true,
161170
'sidebar-fixed':this.position==='fixed'&&!mobile,
162171
'sidebar-narrow':this.narrow&&!this.unfoldable,
163-
'sidebar-narrow-unfoldable':unfoldable,
172+
'sidebar-narrow-unfoldable':this.unfoldable,
164173
'sidebar-overlaid':this.overlaid,
165174
[`sidebar-${this.size}`]:!!this.size,
166175
show:visible&&this.onMobile,
@@ -232,12 +241,13 @@ export class SidebarComponent implements OnChanges, OnDestroy, OnInit {
232241

233242
this.layoutChangeSubscription=layoutChanges.subscribe((result:BreakpointState)=>{
234243
constisOnMobile=result.breakpoints[onMobile];
244+
constisUnfoldable=isOnMobile ?false :this.unfoldable;
235245
if(this.onMobile!==isOnMobile){
236246
this.onMobile=isOnMobile;
237247
this.sidebarService.toggle({
238248
mobile:isOnMobile,
239-
unfoldable:isOnMobile ?false :this.unfoldable,
240-
visible:isOnMobile ?false :this.visible,
249+
unfoldable:isUnfoldable,
250+
visible:(!isOnMobile)||isUnfoldable,
241251
sidebar:this
242252
});
243253
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp