Skip to content

Commit

Permalink
Fixed #740
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed May 29, 2017
1 parent dceee36 commit 454f614
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
21 changes: 19 additions & 2 deletions components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Dialog implements AfterViewInit,OnDestroy {

@Input() closable: boolean = true;

@Input() responsive: boolean;
@Input() responsive: boolean = true;

@Input() appendTo: any;

Expand All @@ -83,6 +83,8 @@ export class Dialog implements AfterViewInit,OnDestroy {

@Input() showHeader: boolean = true;

@Input() breakpoint: number = 640;

@ContentChild(Header) headerFacet;

@ViewChild('container') containerViewChild: ElementRef;
Expand Down Expand Up @@ -122,6 +124,8 @@ export class Dialog implements AfterViewInit,OnDestroy {
mask: HTMLDivElement;

closeIconMouseDown: boolean;

preWidth: number;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2) {}

Expand Down Expand Up @@ -200,7 +204,19 @@ export class Dialog implements AfterViewInit,OnDestroy {

if(this.responsive) {
this.documentResponsiveListener = this.renderer.listen('window', 'resize', (event) => {
this.positionOverlay();
let viewport = this.domHandler.getViewport();
let width = this.domHandler.getOuterWidth(this.containerViewChild.nativeElement);
if(viewport.width <= this.breakpoint) {
if(!this.preWidth) {
this.preWidth = width;
}
this.containerViewChild.nativeElement.style.left = '0px';
this.containerViewChild.nativeElement.style.width = '100%';
}
else {
this.containerViewChild.nativeElement.style.width = this.preWidth + 'px';
this.positionOverlay();
}
});
}

Expand Down Expand Up @@ -318,6 +334,7 @@ export class Dialog implements AfterViewInit,OnDestroy {

initResize(event: MouseEvent) {
if(this.resizable) {
this.preWidth = null;
this.resizing = true;
this.lastPageX = event.pageX;
this.lastPageY = event.pageY;
Expand Down
8 changes: 7 additions & 1 deletion showcase/demo/dialog/dialogdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,15 @@ <h3>Attributes</h3>
<tr>
<td>responsive</td>
<td>boolean</td>
<td>false</td>
<td>true</td>
<td>In responsive mode, dialog adjusts itself to screen width.</td>
</tr>
<tr>
<td>breakpoint</td>
<td>number</td>
<td>640</td>
<td>Maximum screen width to display the dialog with 100% width in responsive mode.</td>
</tr>
<tr>
<td>appendTo</td>
<td>any</td>
Expand Down

0 comments on commit 454f614

Please sign in to comment.