Added Polymer

This commit is contained in:
Thaum
2014-11-26 10:18:35 +00:00
parent 5eea4714b2
commit 3408ba9e8d
1210 changed files with 394645 additions and 47 deletions

View File

@@ -0,0 +1,22 @@
{
"name": "core-scroll-header-panel",
"private": true,
"dependencies": {
"core-field": "Polymer/core-field#^0.5.0",
"core-icon-button": "Polymer/core-icon-button#^0.5.0",
"core-input": "Polymer/core-input#^0.5.0",
"core-media-query": "Polymer/core-media-query#^0.5.0",
"core-toolbar": "Polymer/core-toolbar#^0.5.0"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/core-scroll-header-panel",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "a9d6ee32874fb5e2209d3aa16b6d7bf6ee54fa80"
},
"_source": "git://github.com/Polymer/core-scroll-header-panel.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-scroll-header-panel"
}

View File

@@ -0,0 +1,4 @@
core-scroll-header-panel
========================
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-scroll-header-panel) for more information.

View File

@@ -0,0 +1,12 @@
{
"name": "core-scroll-header-panel",
"private": true,
"dependencies": {
"core-field": "Polymer/core-field#^0.5.0",
"core-icon-button": "Polymer/core-icon-button#^0.5.0",
"core-input": "Polymer/core-input#^0.5.0",
"core-media-query": "Polymer/core-media-query#^0.5.0",
"core-toolbar": "Polymer/core-toolbar#^0.5.0"
},
"version": "0.5.1"
}

View File

@@ -0,0 +1,58 @@
/*
Copyright (c) 2014 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
*/
:host {
display: block;
position: relative;
overflow: hidden;
}
#mainContainer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-overflow-scrolling: touch;
overflow-x: hidden;
overflow-y: auto;
}
#headerContainer {
position: absolute;
top: 0;
right: 0;
left: 0;
}
.bg-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
#headerBg, #condensedHeaderBg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
}
#condensedHeaderBg {
opacity: 0;
}

View File

@@ -0,0 +1,349 @@
<!--
Copyright (c) 2014 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
-->
<!--
`core-scroll-header-panel` contains a header section and a content section. The
header is initially on the top part of the view but it scrolls away with the
rest of the scrollable content. Upon scrolling slightly up at any point, the
header scrolls back into view. This saves screen space and allows users to
access important controls by easily moving them back to the view.
__Important:__ The `core-scroll-header-panel` will not display if its parent does not have a height.
Using [layout attributes](http://www.polymer-project.org/docs/polymer/layout-attrs.html), you can easily make the `core-scroll-header-panel` fill the screen
<body fullbleed layout vertical>
<core-scroll-header-panel flex>
<core-toolbar>
<div>Hello World!</div>
</core-toolbar>
</core-scroll-header-panel>
</body>
or, if you would prefer to do it in CSS, just give `html`, `body`, and `core-scroll-header-panel` a height of 100%:
html, body {
height: 100%;
margin: 0;
}
core-scroll-header-panel {
height: 100%;
}
`core-scroll-header-panel` works well with `core-toolbar` but can use any element
that represents a header by adding a `core-header` class to it.
<core-scroll-header-panel>
<core-toolbar>Header</core-toolbar>
<div>Content goes here...</div>
</core-scroll-header-panel>
@group Polymer Core Elements
@element core-scroll-header-panel
@homepage github.io
-->
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="core-scroll-header-panel">
<template>
<link rel="stylesheet" href="core-scroll-header-panel.css">
<div id="mainContainer">
<content id="mainContent" select=":not(core-toolbar):not(.core-header)"></content>
</div>
<div id="headerContainer">
<div class="bg-container">
<div id="condensedHeaderBg"></div>
<div id="headerBg"></div>
</div>
<content id="headerContent" select="core-toolbar, .core-header"></content>
</div>
</template>
<script>
(function() {
Polymer('core-scroll-header-panel', {
/**
* Fired when the content has been scrolled.
*
* @event scroll
*/
/**
* Fired when the header is transformed.
*
* @event core-header-transform
*/
publish: {
/**
* If true, the header's height will condense to `_condensedHeaderHeight`
* as the user scrolls down from the top of the content area.
*
* @attribute condenses
* @type boolean
* @default false
*/
condenses: false,
/**
* If true, no cross-fade transition from one background to another.
*
* @attribute noDissolve
* @type boolean
* @default false
*/
noDissolve: false,
/**
* If true, the header doesn't slide back in when scrolling back up.
*
* @attribute noReveal
* @type boolean
* @default false
*/
noReveal: false,
/**
* If true, the header is fixed to the top and never moves away.
*
* @attribute fixed
* @type boolean
* @default false
*/
fixed: false,
/**
* If true, the condensed header is always shown and does not move away.
*
* @attribute keepCondensedHeader
* @type boolean
* @default false
*/
keepCondensedHeader: false,
/**
* The height of the header when it is at its full size.
*
* By default, the height will be measured when it is ready. If the height
* changes later the user needs to either set this value to reflect the
* new height or invoke `measureHeaderHeight()`.
*
* @attribute headerHeight
* @type number
* @default 0
*/
headerHeight: 0,
/**
* The height of the header when it is condensed.
*
* By default, `_condensedHeaderHeight` is 1/3 of `headerHeight` unless
* this is specified.
*
* @attribute condensedHeaderHeight
* @type number
* @default 0
*/
condensedHeaderHeight: 0,
/**
* By default, the top part of the header stays when the header is being
* condensed. Set this to true if you want the top part of the header
* to be scrolled away.
*
* @attribute scrollAwayTopbar
* @type boolean
* @default false
*/
scrollAwayTopbar: false
},
prevScrollTop: 0,
headerMargin: 0,
y: 0,
observe: {
'headerMargin fixed': 'setup'
},
ready: function() {
this._scrollHandler = this.scroll.bind(this);
this.scroller.addEventListener('scroll', this._scrollHandler);
},
detached: function() {
this.scroller.removeEventListener('scroll', this._scrollHandler);
},
domReady: function() {
this.async('measureHeaderHeight');
},
get header() {
return this.$.headerContent.getDistributedNodes()[0];
},
/**
* Returns the scrollable element.
*
* @property scroller
* @type Object
*/
get scroller() {
return this.$.mainContainer;
},
/**
* Invoke this to tell `core-scroll-header-panel` to re-measure the header's
* height.
*
* @method measureHeaderHeight
*/
measureHeaderHeight: function() {
var header = this.header;
if (header && header.offsetHeight) {
this.headerHeight = header.offsetHeight;
}
},
headerHeightChanged: function() {
if (!this.condensedHeaderHeight) {
// assume _condensedHeaderHeight is 1/3 of the headerHeight
this._condensedHeaderHeight = this.headerHeight * 1 / 3;
}
this.condensedHeaderHeightChanged();
},
condensedHeaderHeightChanged: function() {
if (this.condensedHeaderHeight) {
this._condensedHeaderHeight = this.condensedHeaderHeight;
}
if (this.headerHeight) {
this.headerMargin = this.headerHeight - this._condensedHeaderHeight;
}
},
condensesChanged: function() {
if (this.condenses) {
this.scroll();
} else {
// reset transform/opacity set on the header
this.condenseHeader(null);
}
},
setup: function() {
var s = this.scroller.style;
s.paddingTop = this.fixed ? '' : this.headerHeight + 'px';
s.top = this.fixed ? this.headerHeight + 'px' : '';
if (this.fixed) {
this.transformHeader(null);
} else {
this.scroll();
}
},
transformHeader: function(y) {
var s = this.$.headerContainer.style;
this.translateY(s, -y);
if (this.condenses) {
this.condenseHeader(y);
}
this.fire('core-header-transform', {y: y, height: this.headerHeight,
condensedHeight: this._condensedHeaderHeight});
},
condenseHeader: function(y) {
var reset = y == null;
// adjust top bar in core-header so the top bar stays at the top
if (!this.scrollAwayTopbar && this.header.$ && this.header.$.topBar) {
this.translateY(this.header.$.topBar.style,
reset ? null : Math.min(y, this.headerMargin));
}
// transition header bg
var hbg = this.$.headerBg.style;
if (!this.noDissolve) {
hbg.opacity = reset ? '' : (this.headerMargin - y) / this.headerMargin;
}
// adjust header bg so it stays at the center
this.translateY(hbg, reset ? null : y / 2);
// transition condensed header bg
var chbg = this.$.condensedHeaderBg.style;
if (!this.noDissolve) {
chbg = this.$.condensedHeaderBg.style;
chbg.opacity = reset ? '' : y / this.headerMargin;
// adjust condensed header bg so it stays at the center
this.translateY(chbg, reset ? null : y / 2);
}
},
translateY: function(s, y) {
var t = y == null ? '' : 'translate3d(0, ' + y + 'px, 0)';
setTransform(s, t);
},
scroll: function(event) {
if (!this.header) {
return;
}
var sTop = this.scroller.scrollTop;
var y = Math.min(this.keepCondensedHeader ?
this.headerMargin : this.headerHeight, Math.max(0,
(this.noReveal ? sTop : this.y + sTop - this.prevScrollTop)));
if (this.condenses && this.prevScrollTop >= sTop && sTop > this.headerMargin) {
y = Math.max(y, this.headerMargin);
}
if (!event || !this.fixed && y !== this.y) {
this.transformHeader(y);
}
this.prevScrollTop = Math.max(sTop, 0);
this.y = y;
if (event) {
this.fire('scroll', {target: this.scroller}, this, false);
}
}
});
//determine proper transform mechanizm
if (document.documentElement.style.transform !== undefined) {
var setTransform = function(style, string) {
style.transform = string;
}
} else {
var setTransform = function(style, string) {
style.webkitTransform = string;
}
}
})();
</script>
</polymer-element>

View File

@@ -0,0 +1,112 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-scroll-header-panel.html">
<link rel="import" href="demos/sample-content.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(demos/images/bg9.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-color: #f4b400;
}
core-toolbar {
color: #f1f1f1;
fill: #f1f1f1;
background-color: transparent;
}
.title {
-webkit-transform-origin: 0;
transform-origin: 0;
font-size: 40px;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel condenses>
<core-toolbar class="tall">
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent title">Title</div>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
<script>
// custom transformation: scale header's title
var titleStyle = document.querySelector('.title').style;
addEventListener('core-header-transform', function(e) {
var d = e.detail;
var m = d.height - d.condensedHeight;
var scale = Math.max(0.75, (m - d.y) / (m / 0.25) + 0.75);
titleStyle.transform = titleStyle.webkitTransform =
'scale(' + scale + ') translateZ(0)';
});
</script>
</body>
</html>

View File

@@ -0,0 +1,81 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo1</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
core-toolbar {
background-color: #4285f4;
color: #f1f1f1;
fill: #f1f1f1;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel>
<core-toolbar>
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex>Title</div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,83 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo2</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
core-toolbar {
background-color: #4285f4;
color: #f1f1f1;
fill: #f1f1f1;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel condenses>
<core-toolbar class="tall">
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent">Title</div>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,82 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo3</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg3.jpg);
}
core-toolbar {
background-color: transparent;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel condenses noReveal noDissolve>
<core-toolbar class="tall">
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo4</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg6.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-color: #ff5722;
}
core-toolbar {
color: #f1f1f1;
fill: #f1f1f1;
background-color: transparent;
}
.title {
font-size: 40px;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel condenses>
<core-toolbar class="tall">
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent title">Title</div>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
<script>
// custom transformation: scale header's title
var titleStyle = document.querySelector('.title').style;
addEventListener('core-header-transform', function(e) {
var d = e.detail;
var m = d.height - d.condensedHeight;
var scale = Math.max(0.75, (m - d.y) / (m / 0.25) + 0.75);
titleStyle.transform = titleStyle.webkitTransform =
'scale(' + scale + ') translateZ(0)';
});
</script>
</body>
</html>

View File

@@ -0,0 +1,110 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo5</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg9.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-color: #f4b400;
}
core-toolbar {
color: #f1f1f1;
fill: #f1f1f1;
background-color: transparent;
}
.title {
font-size: 40px;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel condenses>
<core-toolbar class="tall">
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent title">Title</div>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
<script>
// custom transformation: scale header's title
var titleStyle = document.querySelector('.title').style;
addEventListener('core-header-transform', function(e) {
var d = e.detail;
var m = d.height - d.condensedHeight;
var scale = Math.max(0.75, (m - d.y) / (m / 0.25) + 0.75);
titleStyle.transform = titleStyle.webkitTransform =
'scale(' + scale + ') translateZ(0)';
});
</script>
</body>
</html>

View File

@@ -0,0 +1,114 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo6</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg9.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-image: url(images/bg2.jpg);
}
core-toolbar {
color: #f1f1f1;
fill: #f1f1f1;
/* custom toolbar height */
height: 256px;
background-color: transparent;
}
.title {
font-size: 40px;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<!-- By default condensedHeaderHeight is 1/3 of the header's height. Here
we want to set the condensed header's height to be 64px. -->
<core-scroll-header-panel condenses headerHeight="256" condensedHeaderHeight="64">
<core-toolbar>
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent title">Title</div>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
<script>
// custom transformation: scale header's title
var titleStyle = document.querySelector('.title').style;
addEventListener('core-header-transform', function(e) {
var d = e.detail;
var m = d.height - d.condensedHeight;
var scale = Math.max(0.75, (m - d.y) / (m / 0.25) + 0.75);
titleStyle.transform = titleStyle.webkitTransform =
'scale(' + scale + ') translateZ(0)';
});
</script>
</body>
</html>

View File

@@ -0,0 +1,121 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo7</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<link rel="import" href="../../core-media-query/core-media-query.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg9.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-color: #f4b400;
}
core-toolbar {
color: #f1f1f1;
fill: #f1f1f1;
background-color: transparent;
}
.title {
font-size: 40px;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<core-scroll-header-panel condenses>
<core-toolbar class="tall">
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent title">Title</div>
</core-toolbar>
<div class="content">
<h3>Resize window to toggle between fixed header and scrolled header</h3>
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
<core-media-query id="mquery" query="min-width: 600px"></core-media-query>
<script>
// toggle fixed header based on screen size
var panel = document.querySelector('core-scroll-header-panel');
var mquery = document.querySelector('#mquery');
mquery.addEventListener('core-media-change', function() {
panel.fixed = mquery.queryMatches;
});
// custom transformation: scale header's title
var titleStyle = document.querySelector('.title').style;
addEventListener('core-header-transform', function(e) {
var d = e.detail;
var m = d.height - d.condensedHeight;
var scale = Math.max(0.75, (m - d.y) / (m / 0.25) + 0.75);
titleStyle.transform = titleStyle.webkitTransform =
'scale(' + scale + ') translateZ(0)';
});
</script>
</body>
</html>

View File

@@ -0,0 +1,123 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo8</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg9.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-color: #673ab7;
}
core-toolbar {
color: #f1f1f1;
fill: #f1f1f1;
/* custom toolbar height */
height: 256px;
background-color: transparent;
}
.bottom-text {
-webkit-transform: translateZ(0);
transform: translateZ(0);
font-size: 20px;
padding-bottom: 10px;
}
.subtitle {
padding-top: 4px;
font-size: 16px;
color: #ccc;
}
.bookmark {
position: absolute;
bottom: -24px;
right: 24px;
fill: #4285f4;
height: 48px;
width: 48px;
}
.content {
padding: 16px 10px 16px 50px;
}
</style>
</head>
<body unresolved>
<!-- `keepCondensedHeader` makes the condensed header to not scroll away -->
<core-scroll-header-panel condenses keepCondensedHeader headerHeight="256" condensedHeaderHeight="140">
<core-toolbar>
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="thumb-up"></core-icon-button>
<core-icon-button icon="mail"></core-icon-button>
<div class="bottom indent bottom-text" self-end>
<div>Lorem ipsum dolor sit amet</div>
<div class="subtitle">Iisque perfecto dissentiet cum et</div>
</div>
<core-icon class="bottom bookmark" icon="bookmark"></core-icon>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,101 @@
<!doctype html>
<!--
Copyright (c) 2014 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
-->
<html>
<head>
<title>core-scroll-header-panel: demo9</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-scroll-header-panel.html">
<link rel="import" href="sample-content.html">
<link rel="import" href="../../core-icons/core-icons.html">
<link rel="import" href="../../core-icons/av-icons.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-field/core-field.html">
<link rel="import" href="../../core-input/core-input.html">
<style shim-shadowdom>
html, body {
height: 100%;
}
body {
margin: 0;
font-family: sans-serif;
color: #333;
}
core-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #eee;
}
/* background for toolbar when it is at its full size */
core-scroll-header-panel::shadow #headerBg {
background-image: url(images/bg9.jpg);
}
/* background for toolbar when it is condensed */
core-scroll-header-panel::shadow #condensedHeaderBg {
background-color: transparent;
}
core-field {
background-color: #fff;
border: 1px solid #eee;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
}
core-toolbar {
background-color: transparent;
}
.content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<!-- Instead of using 1/3 of the header's height, we want to manually set the
condensed header's height to 64px -->
<core-scroll-header-panel condenses condensedHeaderHeight="64">
<core-toolbar class="medium-tall">
<core-field flex class="bottom">
<core-icon icon="menu"></core-icon>
<core-input flex></core-input>
<core-icon icon="av:mic"></core-icon>
</core-field>
</core-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</core-scroll-header-panel>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

View File

@@ -0,0 +1,42 @@
<!--
@license
Copyright (c) 2014 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
-->
<polymer-element name="lorem-ipsum" attributes="paragraphs">
<script>
(function() {
var strings = [
'Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea, id minim maiestatis incorrupte duo. Dolorum verterem ad ius, his et nullam verterem. Eu alia debet usu, an doming tritani est. Vix ad ponderum petentium suavitate, eum eu tempor populo, graece sententiae constituam vim ex. Cu torquatos reprimique neglegentur nec, voluptua periculis has ut, at eos discere deleniti sensibus.',
'Ut labores minimum atomorum pro. Laudem tibique ut has. No nam ipsum lorem aliquip, accumsan quaerendum ei usu. Maiestatis vituperatoribus qui at, ne suscipit volutpat tractatos nam. Nonumy semper mollis vis an, nam et harum detracto. An pri dolor percipitur, vel maluisset disputationi te.',
'Fugit adolescens vis et, ei graeci forensibus sed. Denique argumentum comprehensam ei vis, id has facete accommodare, quo scripta utroque id. Autem nullam doming ad eam, te nam dicam iriure periculis. Quem vocent veritus eu vis, nam ut hinc idque feugait.',
'Convenire definiebas scriptorem eu cum. Sit dolor dicunt consectetuer no, in vix nisl velit, duo ridens abhorreant delicatissimi ut. Pro ei libris omnium scripserit, natum volumus propriae no eam. Suscipit pericula explicari sed ei, te usu iudicabit forensibus efficiantur. Has quot dicam animal id.',
'Ea duis bonorum nec, falli paulo aliquid ei eum. Cu mei vide viris gloriatur, at populo eripuit sit. Idque molestiae duo ne. Qui id tempor accusamus sadipscing. His odio feugait et. Ne vis vide labitur, eu corpora appareat interpretaris mel.',
'Usu eu novum principes, vel quodsi aliquip ea. Labore mandamus persequeris id mea, has eripuit neglegentur id, illum noster nec in. Ea nam quod quando cetero, per qualisque tincidunt in. Qui ne meliore commune voluptatibus, qui justo labores no. Et dicat cotidieque eos, vis homero legere et, eam timeam nominavi in. Pri dicam option placerat an, cu qui aliquam adipiscing signiferumque. Vis euismod accusamus no, soluta vocibus ei cum.',
'Has at minim mucius aliquam, est id tempor laoreet. Ius officiis convenire ex, in vim iuvaret patrioque similique, veritus detraxit sed ad. Mel no admodum abhorreant cotidieque, et duo possim postulant, consul convenire adolescens cu mel. Duo in decore soleat doming. Fabellas interpretaris eos at. No cum unum novum dicit.',
'Pro saepe pertinax ei, ad pri animal labores suscipiantur. Modus commodo minimum eum te, vero utinam assueverit per eu, zril oportere suscipiantur pri te. Partem percipitur deterruisset ad sea, at eam suas luptatum dissentiunt. No error alienum pro, erant senserit ex mei, pri semper alterum no. Ut habemus menandri vulputate mea. Feugiat verterem ut sed. Dolores maiestatis id per.',
'Detracto suavitate repudiandae no eum. Id adhuc minim soluta nam, novum denique ad eum. At mucius malorum meliore his, te ferri tritani cum, eu mel legendos ocurreret. His te ludus aperiam malorum, mundi nominati deseruisse pro ne, mel discere intellegat in. Vero dissentiunt quo in, vel cu meis maiestatis adversarium. In sit summo nostrum petentium, ea vix amet nullam minimum, ornatus sensibus theophrastus ex nam.',
'Iisque perfecto dissentiet cum et, sit ut quot mandamus, ut vim tibique splendide instructior. Id nam odio natum malorum, tibique copiosae expetenda mel ea. Mea melius malorum ut. Ut nec tollit vocent timeam. Facer nonumy numquam id his, munere salutatus consequuntur eum et, eum cotidieque definitionem signiferumque id. Ei oblique graecis patrioque vis, et probatus dignissim inciderint vel. Sed id paulo erroribus, autem semper accusamus in mel.'
];
Polymer('lorem-ipsum', {
paragraphs: 0,
paragraphsChanged: function() {
this.innerHTML = '';
for (var i = 0; i < this.paragraphs; i++) {
this.innerHTML += '<p>' + strings[Math.floor(Math.random() * strings.length)] + '</p>';
}
}
});
})();
</script>
</polymer-element>

View File

@@ -0,0 +1,62 @@
<!--
@license
Copyright (c) 2014 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
-->
<polymer-element name="sample-content" attributes="size">
<script>
(function() {
var strings = [
'Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea.',
'Ut labores minimum atomorum pro. Laudem tibique ut has.',
'Fugit adolescens vis et, ei graeci forensibus sed.',
'Convenire definiebas scriptorem eu cum. Sit dolor dicunt consectetuer no.',
'Ea duis bonorum nec, falli paulo aliquid ei eum.',
'Usu eu novum principes, vel quodsi aliquip ea.',
'Has at minim mucius aliquam, est id tempor laoreet.',
'Pro saepe pertinax ei, ad pri animal labores suscipiantur.',
'Detracto suavitate repudiandae no eum. Id adhuc minim soluta nam.',
'Iisque perfecto dissentiet cum et, sit ut quot mandamus, ut vim tibique splendide instructior.',
'Id nam odio natum malorum, tibique copiosae expetenda mel ea.',
'Cu mei vide viris gloriatur, at populo eripuit sit.',
'Modus commodo minimum eum te, vero utinam assueverit per eu.',
'No nam ipsum lorem aliquip, accumsan quaerendum ei usu.'
];
function randomString() {
return strings[Math.floor(Math.random() * strings.length)];
}
function randomLetter() {
return String.fromCharCode(65 + Math.floor(Math.random() * 26));
}
Polymer('sample-content', {
size: 0,
sizeChanged: function() {
this.innerHTML = '';
for (var i = 0; i < this.size; i++) {
this.innerHTML +=
'<div style="border: 1px solid #bebebe; padding: 16px; margin: 16px; border-radius: 5px; background-color: #fff; color: #555;">' +
'<div style="display: inline-block; height: 64px; width: 64px; border-radius: 50%; background: #ddd; line-height: 64px; font-size: 30px; color: #666; text-align: center;">'+ randomLetter() + '</div>' +
'<div style="font-size: 22px; padding: 8px 0 16px; color: #888;">' + randomString() + '</div>' +
'<div style="font-size: 16px; padding-bottom: 8px;">' + randomString() + '</div>' +
'<div style="font-size: 12px;">' + randomString() + '</div>' +
'<div style="font-size: 12px;">' + randomString() + '</div>' +
'</div>';
}
}
});
})();
</script>
</polymer-element>

View File

@@ -0,0 +1,22 @@
<!doctype html>
<!--
Copyright (c) 2014 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
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
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
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<!--
@license
Copyright (c) 2014 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
-->
<x-meta id="core-scroll-header-panel" label="Scroll Header Panel" isContainer group="Core">
<template>
<core-scroll-header-panel condenses style="width: 380px; height: 460px;">
<core-toolbar class="tall" style="background-color: #4285f4; color: #f1f1f1; fill: #f1f1f1;">
<core-icon-button icon="arrow-back"></core-icon-button>
<div flex></div>
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="more-vert"></core-icon-button>
<div class="bottom indent">Title</div>
</core-toolbar>
<section content style="height: 5000px; background: linear-gradient(rgb(214, 227, 231), lightblue);"></section>
</core-scroll-header-panel>
</template>
<template id="imports">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="core-scroll-header-panel.html">
</template>
</x-meta>