Skip to content

Commit

Permalink
Fix issue #97
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia committed Mar 15, 2016
1 parent 73a2092 commit d33c515
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 6 deletions.
4 changes: 3 additions & 1 deletion app-header-layout/app-header-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@

_updateFixedNodesPosition: function() {
var rect = this.getBoundingClientRect();
var rightOffset = document.documentElement.clientWidth - rect.right;

this._getFixedNodes().forEach(function(node) {
node.style.left = this.hasScrollingRegion ? '' : rect.left + 'px';
node.style.width = this.hasScrollingRegion ? '' : rect.width + 'px';
node.style.right = this.hasScrollingRegion ? '' : rightOffset + 'px';
}.bind(this));
},

Expand Down
27 changes: 22 additions & 5 deletions app-header-layout/test/app-header-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
}

app-header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: green;
}

Expand Down Expand Up @@ -78,7 +74,28 @@

test('scrolling region', function() {
headerLayout.hasScrollingRegion = true;
assert.isTrue(header.scroller !== window, 'scroller should not point to the document element');
assert.isTrue(header.scroller !== window, 'scroller should not point to the document element');
});

test('header box size', function(done) {
headerLayout.hasScrollingRegion = false;

flush(function() {
assert.equal(headerLayout.offsetWidth, header.offsetWidth,
'should have the same width of app-header-layout');

headerLayout.style.width = '200px';

headerLayout.resetLayout();

flush(function() {
assert.equal(headerLayout.offsetWidth, header.offsetWidth,
'should have the same width of app-header-layout even after setting a width');
done();
});

});

});

});
Expand Down
76 changes: 76 additions & 0 deletions demo/demo7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">

<title>demo2</title>

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>

<link rel="import" href="../../font-roboto/roboto.html">
<link rel="import" href="../../iron-icons/iron-icons.html">
<link rel="import" href="../../paper-icon-button/paper-icon-button.html">
<link rel="import" href="../app-drawer-layout/app-drawer-layout.html">
<link rel="import" href="../app-drawer/app-drawer.html">
<link rel="import" href="../app-scroll-effects/app-scroll-effects.html">
<link rel="import" href="../app-header/app-header.html">
<link rel="import" href="../app-header-layout/app-header-layout.html">
<link rel="import" href="../app-toolbar/app-toolbar.html">
<link rel="import" href="../demo/sample-content.html">

<style is="custom-style">

body {
margin: 0;
font-family: 'Roboto', 'Noto', sans-serif;
background-color: #eee;
}

app-header {
background-color: #4285f4;
color: #fff;
}

app-header paper-icon-button {
--paper-icon-button-ink-color: white;
}

</style>

</head>
<body unresolved>

<app-drawer-layout>

<app-header-layout>

<app-header fixed effects="waterfall">
<app-toolbar>
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
<div spacer title>My Drive</div>
</app-toolbar>
</app-header>

<sample-content size="100"></sample-content>

</app-header-layout>

<app-drawer align="end">
<app-toolbar>App name</app-toolbar>
</app-drawer>

</app-drawer-layout>

</body>
</html>

0 comments on commit d33c515

Please sign in to comment.