react app

This commit is contained in:
Mario Romano
2016-04-06 17:52:19 +01:00
parent f7e6ef55a2
commit 29df96a085
4425 changed files with 446323 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
{
"name": "paper-scroll-header-panel",
"description": "A header bar with scrolling behavior",
"version": "1.0.15",
"license": "http://polymer.github.io/LICENSE.txt",
"private": true,
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"layout",
"responsive"
],
"main": "paper-scroll-header-panel.html",
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-scroll-header-panel.git"
},
"dependencies": {
"polymer": "Polymer/polymer#^1.0.0",
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0"
},
"devDependencies": {
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"paper-toolbar": "PolymerElements/paper-toolbar#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-media-query": "PolymerElements/iron-media-query#^1.0.0",
"iron-icons": "PolymerElements/iron-icons#^1.0.0",
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
"paper-input": "PolymerElements/paper-input#^1.0.0",
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": [],
"homepage": "https://github.com/PolymerElements/paper-scroll-header-panel",
"_release": "1.0.15",
"_resolution": {
"type": "version",
"tag": "v1.0.15",
"commit": "9e264cc643fc36d5b35597d20623f504914ac04e"
},
"_source": "git://github.com/PolymerElements/paper-scroll-header-panel.git",
"_target": "~1.0.15",
"_originalSource": "PolymerElements/paper-scroll-header-panel",
"_direct": true
}

View File

@@ -0,0 +1 @@
bower_components

View File

@@ -0,0 +1,25 @@
language: node_js
sudo: false
before_script:
- npm install -g bower polylint web-component-tester
- bower install
- polylint
env:
global:
- secure: XFAsPXpYVWqsvZ5NX0ueW63LYhGN560ZPdFbntpau2vYIiuLKwe5N5y3pjw+zE1aJ+MV/JcW7snvP9mimdBQoKj77PLFqzo6wSozaDeV8Zx7PitkztC3rByn9WDVLO8qmlWGqFfedY24Whd4YIHAbBk7V89vaIFPZToTUm0rlUKlsaBWlhViEeG9YxmHoIUXJoRwq9pZ6enFYGIbritYlvcdMnOmTN8AJXqe2hmFel1TzE+e0z67yJdzEFBfkEgGgTAmBKpwFugFyUupOq9ZeFqoD2rg05xgfmtcUv7wrJei6/XqQ5gwbRFS+1Sbjv9AsY02hKFqmToD8a+IXjnxRB2s3OQOF/GFH70RRUeeQW+VOp9jFUaiSMdTghHhj5uMqEQPT0sxvaB+si9R8+g1cYJLaKgT3HoeJtFjcaDYwKkAiFK0ZWhL84JFbxWRqvnAf3gdgK+UWrs517amVaV0cyBjyzrIPtrgACNzJyON32sZEfuLDAKtDfpHf18rfY/QLRO/D8GjB+aWSDA2FzDe7Lrdfhrfgw/fnHq9A4ohS4swBeW8IUC5imN4Eh3FqB/GjVz6q7H0cfmxMre+b0RFCK74HroFW+or/tG5K+Tw7Z51j7NwLt8YGwyfsUDzUZpQ7jUbnW3y/5HJGHov81LkQPESZP4KxWSEYTwXnWrLKk4=
- secure: xJhCDzTM2Ud1hx17cjcMDRtI0+IzrZbvY1vYK6OhX//fP1JTatIHOsXvBVFYfHCdutib6zkKaLTi8AF3oBYdZd7BF1c8Pfv1woZtML5hKb9Ti5VdGsino8Hr0IrInCQaqE+VM+C0Jn9xbsYYMCIMvI77L8kM6HY6Qno8S3Iw99mnxZxWIOKlcwCANlOPGNxOQ3wwJITYStSniBWIwS+51yjlWL1KOhRFWi3m8tFa/eGd4dO13jUb00GPRSluzGXevhtXX78niOB53a6GLT1uObx+zsStvDJeH6HEaXzamvQFMIPtwTCIPlM90AYCaktcgrIfJeRzjG8TOsWz/DuISsRKuuZ5N+yUKp8etD1YzgR3CqQq/NqeNp8TgsKwmifLFiOv75kCvKSvDpRvNjeimwW7jI+EzM0VKewdpJGSMywhHCWTEk3qZ0Vajma6OQcV7FjpwUfheSAAs4j6vYy4/EsKcfAQ9S9eEM85yOlM2NdoNgoQsxUNSM0z01wpxP5c70bgsA3eZRSXIdPXXrd4AuyMzN/o9gkxiTSeWASE4r+OqIJfoXDXYbIH+FtGBgJAE1oPbFDolXC6HNb3C2VwsMrEJP5FMHeqy5FNqLiy0cyl4GfxzNFQz/mIPA/QOpZ80UFIfOl8ptPn2tDloV4mO9TRiE0eXHbr4UOoVH677ew=
- CXX=g++-4.8
node_js: stable
addons:
firefox: latest
apt:
sources:
- google-chrome
- ubuntu-toolchain-r-test
packages:
- google-chrome-stable
- g++-4.8
sauce_connect: true
script:
- xvfb-run wct
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"

View File

@@ -0,0 +1,77 @@
<!--
This file is autogenerated based on
https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
If you edit that file, it will get updated everywhere else.
If you edit this file, your changes will get overridden :)
You can however override the jsbin link with one that's customized to this
specific element:
jsbin=https://jsbin.com/cagaye/edit?html,output
-->
# Polymer Elements
## Guide for Contributors
Polymer Elements are built in the open, and the Polymer authors eagerly encourage any and all forms of community contribution. When contributing, please follow these guidelines:
### Filing Issues
**If you are filing an issue to request a feature**, please provide a clear description of the feature. It can be helpful to describe answers to the following questions:
1. **Who will use the feature?** _“As someone filling out a form…”_
2. **When will they use the feature?** _“When I enter an invalid value…”_
3. **What is the users goal?** _“I want to be visually notified that the value needs to be corrected…”_
**If you are filing an issue to report a bug**, please provide:
1. **A clear description of the bug and related expectations.** Consider using the following example template for reporting a bug:
```markdown
The `paper-foo` element causes the page to turn pink when clicked.
## Expected outcome
The page stays the same color.
## Actual outcome
The page turns pink.
## Steps to reproduce
1. Put a `paper-foo` element in the page.
2. Open the page in a web browser.
3. Click the `paper-foo` element.
```
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
### Submitting Pull Requests
**Before creating a pull request**, please ensure that an issue exists for the corresponding change in the pull request that you intend to make. **If an issue does not exist, please create one per the guidelines above**. The goal is to discuss the design and necessity of the proposed change with Polymer authors and community before diving into a pull request.
When submitting pull requests, please provide:
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, fixes #40
```
2. **A succinct description of the design** used to fix any related issues. For example:
```markdown
This fixes #20 by removing styles that leaked which would cause the page to turn pink whenever `paper-foo` is clicked.
```
3. **At least one test for each bug fixed or feature added** as part of the pull request. Pull requests that fix bugs or add features without accompanying tests will not be considered.
If a proposed change contains multiple commits, please [squash commits](https://www.google.com/url?q=http://blog.steveklabnik.com/posts/2012-11-08-how-to-squash-commits-in-a-github-pull-request) to as few as is necessary to succinctly express the change. A Polymer author can help you squash commits, so dont be afraid to ask us if you need help with that!

View File

@@ -0,0 +1,78 @@
<!---
This README is automatically generated from the comments in these files:
paper-scroll-header-panel.html
Edit those files, and our readme bot will duplicate them over here!
Edit this file, and the bot will squash your changes :)
The bot does some handling of markdown. Please file a bug if it does the wrong
thing! https://github.com/PolymerLabs/tedium/issues
-->
[![Build status](https://travis-ci.org/PolymerElements/paper-scroll-header-panel.svg?branch=master)](https://travis-ci.org/PolymerElements/paper-scroll-header-panel)
_[Demo and API docs](https://elements.polymer-project.org/elements/paper-scroll-header-panel)_
##&lt;paper-scroll-header-panel&gt;
Material design: [Scrolling techniques](https://www.google.com/design/spec/patterns/scrolling-techniques.html)
`paper-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 `paper-scroll-header-panel` will not display if its parent does not have a height.
Using [layout classes](https://www.polymer-project.org/1.0/docs/migration.html#layout-attributes) or custom properties, you can easily make the `paper-scroll-header-panel` fill the screen
```html
<body class="fullbleed layout vertical">
<paper-scroll-header-panel class="flex">
<paper-toolbar>
<div>Hello World!</div>
</paper-toolbar>
</paper-scroll-header-panel>
</body>
```
or, if you would prefer to do it in CSS, just give `html`, `body`, and `paper-scroll-header-panel` a height of 100%:
```css
html, body {
height: 100%;
margin: 0;
}
paper-scroll-header-panel {
height: 100%;
}
```
`paper-scroll-header-panel` works well with `paper-toolbar` but can use any element
that represents a header by adding a `paper-header` class to it.
```html
<paper-scroll-header-panel>
<div class="paper-header">Header</div>
<div>Content goes here...</div>
</paper-scroll-header-panel>
```
### Styling
=======
The following custom properties and mixins are available for styling:
| Custom property | Description | Default |
| --- | --- | --- |
| --paper-scroll-header-panel-full-header | To change background for toolbar when it is at its full size | {} |
| --paper-scroll-header-panel-condensed-header | To change the background for toolbar when it is condensed | {} |
| --paper-scroll-header-container | To override or add container styles | {} |

View File

@@ -0,0 +1,37 @@
{
"name": "paper-scroll-header-panel",
"description": "A header bar with scrolling behavior",
"version": "1.0.15",
"license": "http://polymer.github.io/LICENSE.txt",
"private": true,
"authors": "The Polymer Authors",
"keywords": [
"web-components",
"polymer",
"layout",
"responsive"
],
"main": "paper-scroll-header-panel.html",
"repository": {
"type": "git",
"url": "git://github.com/PolymerElements/paper-scroll-header-panel.git"
},
"dependencies": {
"polymer": "Polymer/polymer#^1.0.0",
"iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0"
},
"devDependencies": {
"paper-styles": "PolymerElements/paper-styles#^1.0.0",
"paper-toolbar": "PolymerElements/paper-toolbar#^1.0.0",
"iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0",
"iron-media-query": "PolymerElements/iron-media-query#^1.0.0",
"iron-icons": "PolymerElements/iron-icons#^1.0.0",
"paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0",
"paper-input": "PolymerElements/paper-input#^1.0.0",
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
"web-component-tester": "^4.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": []
}

View File

@@ -0,0 +1,90 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: Combine with paper-drawer-panel</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-drawer-panel/paper-drawer-panel.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
}
paper-toolbar {
background-color: var(--google-blue-500, #4285f4);
}
paper-toolbar .title {
margin: 0 8px;
}
paper-scroll-header-panel .content {
padding: 8px;
}
</style>
</head>
<body unresolved>
<paper-drawer-panel>
<paper-header-panel drawer>
<paper-toolbar>Menu</paper-toolbar>
</paper-header-panel>
<paper-scroll-header-panel main>
<paper-toolbar>
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="flex title">Title</div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</paper-drawer-panel>
</body>
</html>

View File

@@ -0,0 +1,88 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: demo3</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg2.jpg);
background-position: top left;
};
}
paper-toolbar {
background-color: transparent;
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel condenses no-reveal no-dissolve>
<paper-toolbar class="tall">
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@@ -0,0 +1,115 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: demo4</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg1.jpg);
background-position: left center;
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: var(--paper-deep-purple-500);
};
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
paper-toolbar.tall {
background-color: transparent;
}
paper-toolbar.tall .title {
font-size: 40px;
margin-left: 60px;
-webkit-transform-origin: left center;
transform-origin: left center;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel condenses>
<paper-toolbar class="tall">
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom title">Title</div>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
<script>
// custom transformation: scale header's title
var title = document.querySelector('.title');
addEventListener('paper-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);
Polymer.Base.transform('scale(' + scale + ') translateZ(0)', title);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,86 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: demo1</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);;
}
paper-toolbar {
background-color: var(--google-blue-500, #4285f4);
}
paper-toolbar .title {
margin: 0 8px;
}
paper-scroll-header-panel .content {
padding: 8px;
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel fixed>
<paper-toolbar>
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer title">Title</div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</body>
</html>

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
-->
<dom-module 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>
</dom-module>

View File

@@ -0,0 +1,72 @@
<!--
@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
-->
<dom-module id="sample-content">
<template>
<div id="content"></div>
</template>
</dom-module>
<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({
is: 'sample-content',
properties: {
size: {
type: Number,
value: 0,
observer: 'sizeChanged'
}
},
sizeChanged: function() {
var html = '';
for (var i = 0; i < this.size; i++) {
html +=
'<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>';
this.$.content.innerHTML = html;
}
}
});
})();
</script>

View File

@@ -0,0 +1,130 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: demo7</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../iron-media-query/iron-media-query.html">
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg2.jpg);
background-position: left bottom;
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: var(--google-yellow-500, #f4b400);
};
}
paper-toolbar.tall {
background-color: transparent;
}
paper-toolbar.tall .title {
font-size: 40px;
margin-left: 60px;
-webkit-transform-origin: left center;
transform-origin: left center;
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel condenses>
<paper-toolbar class="tall">
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom indent title">Title</div>
</paper-toolbar>
<div class="content">
<h3>Resize window to toggle between fixed header and scrolled header</h3>
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
<iron-media-query id="mquery" query="min-width: 600px"></iron-media-query>
<script>
// toggle fixed header based on screen size
var panel = document.querySelector('paper-scroll-header-panel');
var mquery = document.querySelector('#mquery');
mquery.addEventListener('query-matches-changed', function() {
panel.fixed = mquery.queryMatches;
});
panel.fixed = mquery.queryMatches;
// custom transformation: scale header's title
var title = document.querySelector('.title');
addEventListener('paper-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);
Polymer.Base.transform('scale(' + scale + ') translateZ(0)', title);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,118 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: Transform header</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg1.jpg);
background-position: left center;
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: var(--paper-deep-purple-500);
};
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
paper-toolbar.tall {
background-color: transparent;
}
paper-toolbar.tall .title {
font-size: 40px;
margin-left: 60px;
-webkit-transform-origin: left center;
transform-origin: left center;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel condenses>
<paper-toolbar class="tall">
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom title">Title</div>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
<script>
// custom transformation: scale header's title
var title = document.querySelector('.title');
addEventListener('paper-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);
Polymer.Base.transform('scale(' + scale + ') translateZ(0)', title);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,84 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: transform header</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<link rel="import" href="sample-content.html">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
}
paper-toolbar {
background-color: var(--google-blue-500, #4285f4);
}
paper-toolbar .title {
margin-left: 60px;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel condenses>
<paper-toolbar class="tall">
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom title">Title</div>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,116 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: transform header</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg4.jpg);
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: var(--paper-light-blue-600);
};
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
paper-toolbar.tall {
background-color: transparent;
}
paper-toolbar.tall .title {
font-size: 40px;
margin-left: 60px;
-webkit-transform-origin: left center;
transform-origin: left center;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<paper-scroll-header-panel condenses>
<paper-toolbar class="tall">
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom title">Title</div>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
<script>
// custom transformation: scale header's title
var title = document.querySelector('.title');
addEventListener('paper-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);
Polymer.Base.transform('scale(' + scale + ') translateZ(0)', title);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,119 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: transform header</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg1.jpg);
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-image: url(images/bg4.jpg);
};
}
paper-toolbar.tall {
/* custom toolbar height */
height: 256px;
background-color: transparent;
}
paper-toolbar.tall .title {
font-size: 40px;
margin-left: 60px;
-webkit-transform-origin: left center;
transform-origin: left center;
}
paper-icon-button {
--paper-icon-button-ink-color: white;
}
.content {
padding: 8px;
}
.spacer {
@apply(--layout-flex);
}
</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. -->
<paper-scroll-header-panel condenses header-height="256" condensed-header-height="64">
<paper-toolbar class="tall">
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="search"></paper-icon-button>
<paper-icon-button icon="more-vert"></paper-icon-button>
<div class="bottom title">Title</div>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
<script>
// custom transformation: scale header's title
var title = document.querySelector('.title');
addEventListener('paper-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);
Polymer.Base.transform('scale(' + scale + ') translateZ(0)', title);
});
</script>
</body>
</html>

View File

@@ -0,0 +1,131 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: transform header</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.html">
<link rel="import" href="../../iron-icon/iron-icon.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="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg4.jpg);
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: var(--paper-light-blue-600);
};
}
paper-toolbar {
/* custom toolbar height */
height: 256px;
background-color: transparent;
overflow: visible;
}
paper-icon-button {
margin: 0 8px;
--paper-icon-button-ink-color: white;
}
.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;
}
.indent {
margin-left: 60px;
}
.spacer {
@apply(--layout-flex);
}
</style>
</head>
<body unresolved>
<!-- `keepCondensedHeader` makes the condensed header to not scroll away -->
<paper-scroll-header-panel condenses keep-condensed-header header-height="256" condensed-header-height="140">
<paper-toolbar>
<paper-icon-button icon="arrow-back"></paper-icon-button>
<div class="spacer"></div>
<paper-icon-button icon="thumb-up"></paper-icon-button>
<paper-icon-button icon="mail"></paper-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>
<iron-icon class="bottom bookmark" icon="bookmark"></iron-icon>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,120 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<title>paper-scroll-header-panel: transform header</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../../iron-icon/iron-icon.html">
<link rel="import" href="../../iron-icons/iron-icons.html">
<link rel="import" href="../../iron-icons/av-icons.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.html">
<link rel="import" href="../../paper-input/paper-input.html">
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../../iron-flex-layout/iron-flex-layout.html">
<link rel="import" href="sample-content.html">
<link rel="stylesheet" href="../../paper-styles/demo.css">
<style is="custom-style">
paper-scroll-header-panel {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: var(--paper-grey-200, #eee);
/* background for toolbar when it is at its full size */
--paper-scroll-header-panel-full-header: {
background-image: url(images/bg2.jpg);
};
/* background for toolbar when it is condensed */
--paper-scroll-header-panel-condensed-header: {
background-color: transparent;
};
}
paper-toolbar {
background-color: transparent;
}
.search-box {
background-color: #fff;
border: 1px solid #eee;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
height: 40px;
}
.search-box iron-icon {
color: var(--google-grey-700);
fill: var(--google-grey-700);
margin: 0 8px;
}
.search-box input {
font-size: 20px;
outline: 0;
border: none;
margin-left: 20px;
}
.content {
padding: 8px;
}
.search-box {
@apply(--layout-flex);
@apply(--layout-center);
@apply(--layout-horizontal);
}
.search-box input {
@apply(--layout-flex);
}
</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 -->
<paper-scroll-header-panel condenses condensed-header-height="64">
<paper-toolbar class="medium-tall">
<div class="search-box bottom">
<iron-icon icon="menu"></iron-icon>
<input>
<iron-icon icon="av:mic"></iron-icon>
</div>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225 126" enable-background="new 0 0 225 126" xml:space="preserve">
<g id="background" display="none">
<rect display="inline" fill="#B0BEC5" width="225" height="126"/>
</g>
<g id="label">
</g>
<g id="art">
<circle cx="170.6" cy="28.5" r="4"/>
<circle cx="170.6" cy="58.5" r="4"/>
<rect x="170" y="29" width="2" height="30"/>
<path d="M163,102H73V24h90V102z M75,100h86V26H75V100z"/>
<rect x="74" y="62" width="88" height="2"/>
<g id="ic_x5F_add_x0D_">
</g>
<g>
<polygon points="74,59.6 74,62.5 74.5,63 77.4,63 "/>
<polygon points="74,51.9 74,54.7 82.3,63 85.1,63 "/>
<polygon points="74,44.1 74,46.9 90.1,63 92.9,63 "/>
<polygon points="74,36.3 74,39.2 97.8,63 100.7,63 "/>
<polygon points="74,28.6 74,31.4 105.6,63 108.4,63 "/>
<polygon points="78.2,25 75.4,25 113.4,63 116.2,63 "/>
<polygon points="86,25 83.1,25 121.1,63 124,63 "/>
<polygon points="93.7,25 90.9,25 128.9,63 131.7,63 "/>
<polygon points="101.5,25 98.7,25 136.7,63 139.5,63 "/>
<polygon points="109.2,25 106.4,25 144.4,63 147.2,63 "/>
<polygon points="117,25 114.2,25 152.2,63 155,63 "/>
<polygon points="124.8,25 122,25 160,63 162,63 162,62.2 "/>
<polygon points="132.5,25 129.7,25 162,57.3 162,54.5 "/>
<polygon points="140.3,25 137.5,25 162,49.5 162,46.7 "/>
<polygon points="148.1,25 145.2,25 162,41.8 162,38.9 "/>
<polygon points="155.8,25 153,25 162,34 162,31.2 "/>
<polygon points="162,26.2 162,25 160.8,25 "/>
</g>
</g>
<g id="Guides">
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,28 @@
<!doctype html>
<!--
@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
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>paper-scroll-header-panel</title>
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page></iron-component-page>
</body>
</html>

View File

@@ -0,0 +1,579 @@
<!--
@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
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../iron-resizable-behavior/iron-resizable-behavior.html">
<!--
Material design: [Scrolling techniques](https://www.google.com/design/spec/patterns/scrolling-techniques.html)
`paper-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 `paper-scroll-header-panel` will not display if its parent does not have a height.
Using [layout classes](https://www.polymer-project.org/1.0/docs/migration.html#layout-attributes) or custom properties, you can easily make the `paper-scroll-header-panel` fill the screen
```html
<body class="fullbleed layout vertical">
<paper-scroll-header-panel class="flex">
<paper-toolbar>
<div>Hello World!</div>
</paper-toolbar>
</paper-scroll-header-panel>
</body>
```
or, if you would prefer to do it in CSS, just give `html`, `body`, and `paper-scroll-header-panel` a height of 100%:
```css
html, body {
height: 100%;
margin: 0;
}
paper-scroll-header-panel {
height: 100%;
}
```
`paper-scroll-header-panel` works well with `paper-toolbar` but can use any element
that represents a header by adding a `paper-header` class to it.
```html
<paper-scroll-header-panel>
<div class="paper-header">Header</div>
<div>Content goes here...</div>
</paper-scroll-header-panel>
```
### Styling
=======
The following custom properties and mixins are available for styling:
Custom property | Description | Default
----------------|-------------|----------
--paper-scroll-header-panel-full-header | To change background for toolbar when it is at its full size | {}
--paper-scroll-header-panel-condensed-header | To change the background for toolbar when it is condensed | {}
--paper-scroll-header-container | To override or add container styles | {}
@group Paper Element
@element paper-scroll-header-panel
@demo demo/transform-header-1.html Transform header 1
@demo demo/transform-header-2.html Transform header 2
@demo demo/transform-header-3.html Transform header 3
@demo demo/transform-header-4.html Transform header 4
@demo demo/transform-header-5.html Transform header 5
@demo demo/transform-header-6.html Transform header 6
@demo demo/keep-header.html Keep header
@demo demo/hide-header.html Hide header
@demo demo/toggle-fixed-header.html Toggle fixed header
@demo demo/drawer-panel.html Combine with paper-drawer-panel
@hero hero.svg
-->
<dom-module id="paper-scroll-header-panel">
<style>
:host {
display: block;
position: relative;
overflow: hidden;
}
#mainContainer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
overflow-x: hidden;
overflow-y: auto;
@apply(--paper-scroll-header-container);
}
#headerContainer {
position: absolute;
top: 0;
right: 0;
left: 0;
}
.bg-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
#headerBg {
@apply(--paper-scroll-header-panel-full-header);
}
#condensedHeaderBg {
@apply(--paper-scroll-header-panel-condensed-header);
}
#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;
}
</style>
<template>
<div id="mainContainer">
<content id="mainContent" select=":not(paper-toolbar):not(.paper-header)"></content>
</div>
<div id="headerContainer">
<div class="bg-container">
<div id="condensedHeaderBg"></div>
<div id="headerBg"></div>
</div>
<content id="headerContent" select="paper-toolbar, .paper-header"></content>
</div>
</template>
</dom-module>
<script>
(function() {
'use strict';
Polymer.PaperScrollHeaderPanel = Polymer({
/**
* Fired when the content has been scrolled.
*
* @event content-scroll
*/
/**
* Fired when the header is transformed.
*
* @event paper-header-transform
*/
is: 'paper-scroll-header-panel',
behaviors: [
Polymer.IronResizableBehavior
],
properties: {
/**
* If true, the header's height will condense to `condensedHeaderHeight`
* as the user scrolls down from the top of the content area.
*/
condenses: {
type: Boolean,
value: false
},
/**
* If true, no cross-fade transition from one background to another.
*/
noDissolve: {
type: Boolean,
value: false
},
/**
* If true, the header doesn't slide back in when scrolling back up.
*/
noReveal: {
type: Boolean,
value: false
},
/**
* If true, the header is fixed to the top and never moves away.
*/
fixed: {
type: Boolean,
value: false
},
/**
* If true, the condensed header is always shown and does not move away.
*/
keepCondensedHeader: {
type: Boolean,
value: 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()`.
*/
headerHeight: {
type: Number,
value: 0
},
/**
* The height of the header when it is condensed.
*
* By default, `condensedHeaderHeight` is 1/3 of `headerHeight` unless
* this is specified.
*/
condensedHeaderHeight: {
type: Number,
value: 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.
*/
scrollAwayTopbar: {
type: Boolean,
value: false
},
/**
* The state of the header. Depending on the configuration and the `scrollTop` value,
* the header state could change to
* Polymer.PaperScrollHeaderPanel.HEADER_STATE_EXPANDED
* Polymer.PaperScrollHeaderPanel.HEADER_STATE_HIDDEN
* Polymer.PaperScrollHeaderPanel.HEADER_STATE_CONDENSED
* Polymer.PaperScrollHeaderPanel.HEADER_STATE_INTERPOLATED
*/
headerState: {
type: Number,
readOnly: true,
notify:true,
value: 0
},
/** @type {number|null} */
_defaultCondsensedHeaderHeight: {
type: Number,
value: 0
}
},
observers: [
'_setup(headerHeight, condensedHeaderHeight, fixed)',
'_condensedHeaderHeightChanged(condensedHeaderHeight)',
'_headerHeightChanged(headerHeight, condensedHeaderHeight)',
'_condensesChanged(condenses)',
],
listeners: {
'iron-resize': 'measureHeaderHeight'
},
ready: function() {
this._scrollHandler = this._scroll.bind(this);
this.scroller.addEventListener('scroll', this._scrollHandler);
},
attached: function() {
this.async(this.measureHeaderHeight, 1);
},
/**
* Returns the header element.
*
* @property header
* @type Object
*/
get header() {
return Polymer.dom(this.$.headerContent).getDistributedNodes()[0];
},
/**
* Returns the content element.
*
* @property content
* @type Object
*/
get content() {
return Polymer.dom(this.$.mainContent).getDistributedNodes()[0];
},
/**
* Returns the scrollable element.
*
* @property scroller
* @type Object
*/
get scroller() {
return this.$.mainContainer;
},
get _headerMaxDelta() {
return this.keepCondensedHeader ? this._headerMargin : this.headerHeight;
},
get _headerMargin() {
return this.headerHeight - this.condensedHeaderHeight;
},
_y: 0,
_prevScrollTop: 0,
/**
* Invoke this to tell `paper-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;
}
},
/**
* Scroll to a specific y coordinate.
*
* @method scroll
* @param {number} top The coordinate to scroll to, along the y-axis.
* @param {boolean} smooth true if the scroll position should be smoothly adjusted.
*/
scroll: function(top, smooth) {
// the scroll event will trigger _updateScrollState directly,
// However, _updateScrollState relies on the previous `scrollTop` to update the states.
// Calling _updateScrollState will ensure that the states are synced correctly.
if (smooth) {
// TODO(blasten): use CSS scroll-behavior once it ships in Chrome.
var easingFn = function easeOutQuad(t, b, c, d) {
t /= d;
return -c * t*(t-2) + b;
};
var animationId = Math.random();
var duration = 200;
var startTime = Date.now();
var currentScrollTop = this.scroller.scrollTop;
var deltaScrollTop = top - currentScrollTop;
this._currentAnimationId = animationId;
(function updateFrame() {
var now = Date.now();
var elapsedTime = now - startTime;
if (elapsedTime > duration) {
this.scroller.scrollTop = top;
this._updateScrollState(top);
} else if (this._currentAnimationId === animationId) {
this.scroller.scrollTop = easingFn(elapsedTime, currentScrollTop, deltaScrollTop, duration);
requestAnimationFrame(updateFrame.bind(this));
}
}).call(this);
} else {
this.scroller.scrollTop = top;
this._updateScrollState(top);
}
},
/**
* Condense the header.
*
* @method condense
* @param {boolean} smooth true if the scroll position should be smoothly adjusted.
*/
condense: function(smooth) {
if (this.condenses && !this.fixed && !this.noReveal) {
switch (this.headerState) {
case 1:
this.scroll(this.scroller.scrollTop - (this._headerMaxDelta - this._headerMargin), smooth);
break;
case 0:
case 3:
this.scroll(this._headerMargin, smooth);
break;
}
}
},
/**
* Scroll to the top of the content.
*
* @method scrollToTop
* @param {boolean} smooth true if the scroll position should be smoothly adjusted.
*/
scrollToTop: function(smooth) {
this.scroll(0, smooth);
},
_headerHeightChanged: function(headerHeight) {
if (this._defaultCondsensedHeaderHeight !== null) {
this._defaultCondsensedHeaderHeight = Math.round(headerHeight * 1/3);
this.condensedHeaderHeight = this._defaultCondsensedHeaderHeight;
}
},
_condensedHeaderHeightChanged: function(condensedHeaderHeight) {
if (condensedHeaderHeight) {
// a user custom value
if (this._defaultCondsensedHeaderHeight != condensedHeaderHeight) {
// disable the default value
this._defaultCondsensedHeaderHeight = null;
}
}
},
_condensesChanged: function() {
this._updateScrollState(this.scroller.scrollTop);
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._setHeaderState(0);
this._transformHeader(null);
} else {
switch (this.headerState) {
case 1:
this._transformHeader(this._headerMaxDelta);
break;
case 2:
this._transformHeader(this._headerMargin);
break;
}
}
},
_transformHeader: function(y) {
this._translateY(this.$.headerContainer, -y);
if (this.condenses) {
this._condenseHeader(y);
}
this.fire('paper-header-transform',
{ y: y,
height: this.headerHeight,
condensedHeight: this.condensedHeaderHeight
}
);
},
_condenseHeader: function(y) {
var reset = (y === null);
// adjust top bar in paper-header so the top bar stays at the top
if (!this.scrollAwayTopbar && this.header && this.header.$ && this.header.$.topBar) {
this._translateY(this.header.$.topBar,
reset ? null : Math.min(y, this._headerMargin));
}
// transition header bg
if (!this.noDissolve) {
this.$.headerBg.style.opacity = reset ? '' :
( (this._headerMargin - y) / this._headerMargin);
}
// adjust header bg so it stays at the center
this._translateY(this.$.headerBg, reset ? null : y / 2);
// transition condensed header bg
if (!this.noDissolve) {
this.$.condensedHeaderBg.style.opacity = reset ? '' :
(y / this._headerMargin);
// adjust condensed header bg so it stays at the center
this._translateY(this.$.condensedHeaderBg, reset ? null : y / 2);
}
},
_translateY: function(node, y) {
this.transform((y === null) ? '' : 'translate3d(0, ' + y + 'px, 0)', node);
},
/** @param {Event=} event */
_scroll: function(event) {
if (this.header) {
this._updateScrollState(this.scroller.scrollTop);
this.fire('content-scroll', {
target: this.scroller
},
{
cancelable: false
});
}
},
_updateScrollState: function(scrollTop) {
var deltaScrollTop = scrollTop - this._prevScrollTop;
var y = Math.max(0, (this.noReveal) ? scrollTop : this._y + deltaScrollTop);
if (y > this._headerMaxDelta) {
y = this._headerMaxDelta;
if (this.keepCondensedHeader) {
this._setHeaderState(2);
} else {
this._setHeaderState(1);
}
} else if (this.condenses && scrollTop >= this._headerMargin) {
y = Math.max(y, this._headerMargin);
this._setHeaderState(2);
} else if (y === 0) {
this._setHeaderState(0);
} else {
this._setHeaderState(3);
}
if (!this.fixed && y !== this._y) {
this._transformHeader(y);
}
this._prevScrollTop = Math.max(scrollTop, 0);
this._y = y;
}
});
Polymer.PaperScrollHeaderPanel.HEADER_STATE_EXPANDED = 0;
Polymer.PaperScrollHeaderPanel.HEADER_STATE_HIDDEN = 1;
Polymer.PaperScrollHeaderPanel.HEADER_STATE_CONDENSED = 2;
Polymer.PaperScrollHeaderPanel.HEADER_STATE_INTERPOLATED = 3;
})();
</script>

View File

@@ -0,0 +1,127 @@
<!doctype html>
<!--
@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
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>
<meta charset="UTF-8">
<title>paper-scroll-header-panel test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../demo/sample-content.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head>
<body>
<test-fixture id="trivialProgress">
<template>
<paper-scroll-header-panel>
<paper-toolbar>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</template>
</test-fixture>
<script>
suite('basic features', function() {
var scrollHeaderPanel, toolbar, content;
setup(function() {
scrollHeaderPanel = fixture('trivialProgress');
toolbar = Polymer.dom(scrollHeaderPanel).querySelector('paper-toolbar');
content = Polymer.dom(scrollHeaderPanel).querySelector('.content');
});
test('check default', function() {
assert.equal(scrollHeaderPanel.header, toolbar);
assert.equal(scrollHeaderPanel.content, content);
assert.equal(scrollHeaderPanel.condenses, false);
assert.equal(scrollHeaderPanel.noReveal, false);
assert.equal(scrollHeaderPanel.fixed, false);
assert.typeOf(scrollHeaderPanel.scroller, 'object');
assert.equal(scrollHeaderPanel.keepCondensedHeader, false);
assert.equal(scrollHeaderPanel.keepCondensedHeader, false);
scrollHeaderPanel.measureHeaderHeight();
assert.equal(scrollHeaderPanel.headerHeight, toolbar.offsetHeight);
assert.equal(scrollHeaderPanel.condensedHeaderHeight, Math.round(toolbar.offsetHeight * 1/3));
});
test('condensation', function(done) {
var top1 = toolbar.getBoundingClientRect().top;
scrollHeaderPanel.condenses = true;
scrollHeaderPanel.headerHeight = 150;
scrollHeaderPanel.condensedHeaderHeight = 50;
scrollHeaderPanel.scroller.scrollTop = 300;
flush(function() {
assert.notEqual(top1, toolbar.getBoundingClientRect().top)
done();
});
});
test('paper-header-transform event', function(done) {
scrollHeaderPanel.condenses = false;
scrollHeaderPanel.headerHeight = scrollHeaderPanel.headerHeight || 150;
scrollHeaderPanel.addEventListener('paper-header-transform', function(e) {
assert.typeOf(e.detail.y, 'number');
assert.equal(e.detail.height, scrollHeaderPanel.headerHeight);
assert.equal(e.detail.condensedHeight, scrollHeaderPanel.condensedHeaderHeight);
done();
});
flush(function() {
scrollHeaderPanel.scroller.scrollTop = 300;
});
});
test('content-scroll event', function(done) {
scrollHeaderPanel.condenses = false;
scrollHeaderPanel.addEventListener('content-scroll', function(e) {
assert.equal(e.detail.target, scrollHeaderPanel.scroller);
done();
});
flush(function() {
scrollHeaderPanel.scroller.scrollTop = 300;
});
});
test('custom `condensedHeaderHeight`', function(done) {
var CUSTOM_HEIGHT = 100;
scrollHeaderPanel.condensedHeaderHeight = CUSTOM_HEIGHT;
scrollHeaderPanel.headerHeight = CUSTOM_HEIGHT;
assert.equal(scrollHeaderPanel.condensedHeaderHeight, CUSTOM_HEIGHT);
assert.equal(scrollHeaderPanel.headerHeight, CUSTOM_HEIGHT);
done();
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,93 @@
<!doctype html>
<!--
@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
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>
<meta charset="UTF-8">
<title>paper-scroll-header-panel test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../demo/sample-content.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head>
<body>
<test-fixture id="trivialProgress">
<template>
<paper-scroll-header-panel condenses>
<paper-toolbar class="tall"></paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</template>
</test-fixture>
<script>
suite('`headerState`', function() {
var scrollHeaderPanel, toolbar;
setup(function() {
scrollHeaderPanel = fixture('trivialProgress');
toolbar = Polymer.dom(scrollHeaderPanel).querySelector('paper-toolbar');
scrollHeaderPanel.measureHeaderHeight();
scrollHeaderPanel.scroll(0);
});
test('HEADER_STATE_EXPANDED', function(done) {
assert.equal(scrollHeaderPanel.headerState, Polymer.PaperScrollHeaderPanel.HEADER_STATE_EXPANDED);
scrollHeaderPanel.scroll(1);
flush(function() {
assert.notEqual(scrollHeaderPanel.headerState, Polymer.PaperScrollHeaderPanel.HEADER_STATE_EXPANDED);
done();
});
});
test('HEADER_STATE_HIDDEN', function(done) {
scrollHeaderPanel.scroll(toolbar.offsetHeight + 1);
//flush(function() {
assert.equal(scrollHeaderPanel.headerState, Polymer.PaperScrollHeaderPanel.HEADER_STATE_HIDDEN);
done();
//});
});
test('HEADER_STATE_CONDENSED', function(done) {
scrollHeaderPanel.scroll(toolbar.offsetHeight - scrollHeaderPanel.condensedHeaderHeight);
setTimeout(function() {
assert.equal(scrollHeaderPanel.headerState, Polymer.PaperScrollHeaderPanel.HEADER_STATE_CONDENSED);
done();
}, 100);
});
test('HEADER_STATE_INTERPOLATED', function(done) {
scrollHeaderPanel.scroll(1);
flush(function() {
assert.equal(scrollHeaderPanel.headerState, Polymer.PaperScrollHeaderPanel.HEADER_STATE_INTERPOLATED);
done();
});
});
});
</script>
</body>
</html>

View File

@@ -0,0 +1,28 @@
<!DOCTYPE html><!--
@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
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>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>Tests</title>
<script src="../../web-component-tester/browser.js"></script>
</head>
<body>
<script>
WCT.loadSuites([
'basic.html',
'header-state.html',
'scroll.html',
'basic.html?dom=shadow',
'header-state.html?dom=shadow',
'scroll.html?dom=shadow'
]);
</script>
</body></html>

View File

@@ -0,0 +1,136 @@
<!doctype html>
<!--
@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
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>
<meta charset="UTF-8">
<title>paper-scroll-header-panel test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<link rel="import" href="../paper-scroll-header-panel.html">
<link rel="import" href="../demo/sample-content.html">
<link rel="import" href="../../paper-toolbar/paper-toolbar.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head>
<body>
<test-fixture id="trivialProgress">
<template>
<paper-scroll-header-panel condenses>
<paper-toolbar>
</paper-toolbar>
<div class="content">
<sample-content size="100"></sample-content>
</div>
</paper-scroll-header-panel>
</template>
</test-fixture>
<script>
suite('scroll', function() {
var scrollHeaderPanel;
setup(function() {
scrollHeaderPanel = fixture('trivialProgress');
scrollHeaderPanel.measureHeaderHeight();
});
teardown(function() {
scrollHeaderPanel.scroll(0);
});
test('scroll smoothly', function(done) {
var destination = 100;
var adjustments = 0;
function check() {
if (scrollHeaderPanel.scroller.scrollTop === destination) {
assert.notEqual(adjustments, 0);
done();
return;
}
adjustments++;
setTimeout(check, 0);
}
scrollHeaderPanel.scroll(destination, true);
check();
});
test('condense smoothly', function(done) {
flush(function() {
var destination = 100;
var adjustments = 0;
function check() {
if (scrollHeaderPanel.headerState === Polymer.PaperScrollHeaderPanel.HEADER_STATE_CONDENSED) {
assert.notEqual(adjustments, 0);
done();
return;
}
adjustments++;
setTimeout(check, 1);
}
scrollHeaderPanel.condense(true);
check();
});
});
test('condense immediately', function(done) {
flush(function() {
scrollHeaderPanel.condense();
assert.equal(scrollHeaderPanel.headerState, Polymer.PaperScrollHeaderPanel.HEADER_STATE_CONDENSED);
done();
});
});
test('scroll to top smoothly', function(done) {
scrollHeaderPanel.scroll(100);
flush(function() {
var adjustments = 0;
function check() {
if (scrollHeaderPanel.scroller.scrollTop === 0) {
assert.notEqual(adjustments, 0);
done();
return;
}
adjustments++;
setTimeout(check, 0);
}
scrollHeaderPanel.scrollToTop(true);
check();
});
});
test('scroll to top immediately', function(done) {
scrollHeaderPanel.scroll(100);
flush(function() {
assert.equal(scrollHeaderPanel.scroller.scrollTop, 100);
scrollHeaderPanel.scrollToTop();
Polymer.Base.async(function() {
assert.equal(scrollHeaderPanel.scroller.scrollTop, 0);
done();
}, 100);
});
});
});
</script>
</body>
</html>