From 7a434b131181699950a7e57a22650e9ae8d2234b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Luis=20Gonz=C3=A1lez=20Paz?= Date: Thu, 23 Jun 2022 06:07:22 -0300 Subject: [PATCH] fix: remove content margin when drawer is closed --- src/fc-applayout.ts | 61 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/src/fc-applayout.ts b/src/fc-applayout.ts index 6008f83..4549460 100644 --- a/src/fc-applayout.ts +++ b/src/fc-applayout.ts @@ -218,28 +218,61 @@ export class FcAppLayoutElement extends ThemableElement { } _updateMargin() { + let marginWidth = this.drawer.clientWidth + "px"; if (this.drawerPersistent) { - let marginWidth = this.drawer.clientWidth + "px"; - if (!this.drawer.opened) { - this.content.style.marginLeft = "0px"; - } - if (!this.drawerBelowHeader) { - if (this.drawerAlign=="right") { - this.header.style.marginRight = marginWidth; + //TRUE TRUE + if(this.drawerBelowHeader){ + if(this.drawer.opened) { + if (this.drawerAlign == "right") { + this.header.style.marginRight = "0px"; + this.content.style.marginRight = marginWidth; + } else { + this.header.style.marginLeft = "0px"; + this.content.style.marginLeft = marginWidth; + } + } else { + if (this.drawerAlign == "right") { + this.header.style.marginRight = "0px"; + this.content.style.marginRight = "0px"; + } else { + this.header.style.marginLeft = "0px"; + this.content.style.marginLeft = "0px"; + } + } + } else {//TRUE FALSE + if(this.drawer.opened) { + if (this.drawerAlign == "right") { + this.header.style.marginRight = marginWidth; + this.content.style.marginRight = marginWidth; + } else { + this.header.style.marginLeft = marginWidth; + this.content.style.marginLeft = marginWidth; + } } else { - this.header.style.marginLeft = marginWidth; + if (this.drawerAlign == "right") { + this.header.style.marginRight = "0px"; + this.content.style.marginRight = "0px"; + } else { + this.header.style.marginLeft = "0px"; + this.content.style.marginLeft = "0px"; + } } } - if (this.drawerAlign=="right") { - this.content.style.marginRight = marginWidth; - } else { - this.content.style.marginLeft = marginWidth; + + } else { + //FALSE TRUE + //FALSE FALSE + if (this.drawerAlign == "right") { + this.header.style.marginRight = "0px"; + this.content.style.marginRight = "0px"; + } else { + this.header.style.marginLeft = "0px"; + this.content.style.marginLeft = "0px"; + } } } } -} - declare global { interface HTMLElementTagNameMap { 'fc-applayout': FcAppLayoutElement;