From c738ce15851a5c4bb6922de219dcd1d9aace38c4 Mon Sep 17 00:00:00 2001 From: Keanu Lee Date: Mon, 20 Jun 2016 11:22:28 -0700 Subject: [PATCH] Slight optimizations --- app-drawer-layout/app-drawer-layout.html | 10 +++++----- app-drawer-layout/test/app-drawer-layout.html | 3 +-- app-drawer/app-drawer.html | 7 +++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app-drawer-layout/app-drawer-layout.html b/app-drawer-layout/app-drawer-layout.html index a61fe792..5f30ce3b 100644 --- a/app-drawer-layout/app-drawer-layout.html +++ b/app-drawer-layout/app-drawer-layout.html @@ -209,13 +209,12 @@ }, resetLayout: function() { - this.debounce('_resetLayout', function() { - if (!this.isAttached) { - return; - } + if (!this.isAttached) { + return; + } + this.debounce('_resetLayout', function() { var drawer = this.drawer; - var drawerWidth = this.drawer.getWidth(); var contentContainer = this.$.contentContainer; if (this.narrow) { @@ -228,6 +227,7 @@ drawer.opened = drawer.persistent = true; contentContainer.classList.remove('narrow'); + var drawerWidth = this.drawer.getWidth(); if (drawer.position == 'right') { contentContainer.style.marginLeft = ''; contentContainer.style.marginRight = drawerWidth + 'px'; diff --git a/app-drawer-layout/test/app-drawer-layout.html b/app-drawer-layout/test/app-drawer-layout.html index f9c96c5c..e012c853 100644 --- a/app-drawer-layout/test/app-drawer-layout.html +++ b/app-drawer-layout/test/app-drawer-layout.html @@ -137,9 +137,8 @@ }); test('content layout', function(done) { - var listenerSpy = sinon.spy(); var xResizeable = drawerLayout.querySelector('x-resizeable'); - xResizeable.addEventListener('iron-resize', listenerSpy); + var listenerSpy = sinon.spy(xResizeable, 'notifyResize'); drawerLayout.responsiveWidth = '10000px'; window.setTimeout(function() { diff --git a/app-drawer/app-drawer.html b/app-drawer/app-drawer.html index de392a39..762e5403 100644 --- a/app-drawer/app-drawer.html +++ b/app-drawer/app-drawer.html @@ -234,7 +234,7 @@ }, observers: [ - 'resetLayout(position)', + 'resetLayout(position, isAttached)', '_resetPosition(align, isAttached)' ], @@ -308,9 +308,8 @@ }, /** - * Resets the layout. If you changed the size of app-header via CSS - * you can notify the changes by either firing the `iron-resize` event - * or calling `resetLayout` directly. + * Resets the layout. The event fired is used by app-drawer-layout to position the + * content. * * @method resetLayout */