update polymer components

This commit is contained in:
Luke Pulverenti 2015-11-17 23:19:22 -05:00
parent 80390fe2a0
commit 019c63c88a
12 changed files with 215 additions and 104 deletions

View file

@ -39,6 +39,6 @@
"commit": "cec8e49744a1e18b14a711eea77e201bb70de544" "commit": "cec8e49744a1e18b14a711eea77e201bb70de544"
}, },
"_source": "git://github.com/desandro/doc-ready.git", "_source": "git://github.com/desandro/doc-ready.git",
"_target": "1.0.x", "_target": "~1.0.4",
"_originalSource": "doc-ready" "_originalSource": "doc-ready"
} }

View file

@ -31,6 +31,6 @@
"commit": "34fc5e4a0f252964ed2790138b8d7d30d04b55c1" "commit": "34fc5e4a0f252964ed2790138b8d7d30d04b55c1"
}, },
"_source": "git://github.com/desandro/get-style-property.git", "_source": "git://github.com/desandro/get-style-property.git",
"_target": "1.x", "_target": "~1.0.4",
"_originalSource": "get-style-property" "_originalSource": "get-style-property"
} }

View file

@ -36,7 +36,7 @@
"tag": "v1.0.8", "tag": "v1.0.8",
"commit": "e9a66727f3da0446f04956d4e4f1dcd51cdec2ff" "commit": "e9a66727f3da0446f04956d4e4f1dcd51cdec2ff"
}, },
"_source": "git://github.com/polymerelements/iron-selector.git", "_source": "git://github.com/PolymerElements/iron-selector.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "polymerelements/iron-selector" "_originalSource": "PolymerElements/iron-selector"
} }

View file

@ -31,14 +31,14 @@
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0",
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0" "iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
}, },
"homepage": "https://github.com/polymerelements/paper-ripple", "homepage": "https://github.com/PolymerElements/paper-ripple",
"_release": "1.0.4", "_release": "1.0.4",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.4", "tag": "v1.0.4",
"commit": "5f5893ca7bd6a8413d2f777c092a1a179b6bd45e" "commit": "5f5893ca7bd6a8413d2f777c092a1a179b6bd45e"
}, },
"_source": "git://github.com/polymerelements/paper-ripple.git", "_source": "git://github.com/PolymerElements/paper-ripple.git",
"_target": "^1.0.0", "_target": "^1.0.0",
"_originalSource": "polymerelements/paper-ripple" "_originalSource": "PolymerElements/paper-ripple"
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "paper-slider", "name": "paper-slider",
"version": "1.0.7", "version": "1.0.8",
"description": "A material design-style slider", "description": "A material design-style slider",
"license": "http://polymer.github.io/LICENSE.txt", "license": "http://polymer.github.io/LICENSE.txt",
"authors": "The Polymer Authors", "authors": "The Polymer Authors",
@ -10,13 +10,12 @@
"slider", "slider",
"control" "control"
], ],
"main": [ "main": "paper-slider.html",
"paper-slider.html"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/PolymerElements/paper-slider.git" "url": "git://github.com/PolymerElements/paper-slider.git"
}, },
"ignore": [],
"dependencies": { "dependencies": {
"polymer": "Polymer/polymer#^1.0.0", "polymer": "Polymer/polymer#^1.0.0",
"paper-input": "PolymerElements/paper-input#^1.0.0", "paper-input": "PolymerElements/paper-input#^1.0.0",
@ -33,15 +32,15 @@
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0", "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0", "test-fixture": "PolymerElements/test-fixture#^1.0.0",
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0", "iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
"web-component-tester": "*", "web-component-tester": "polymer/web-component-tester#^3.4.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
}, },
"homepage": "https://github.com/PolymerElements/paper-slider", "homepage": "https://github.com/PolymerElements/paper-slider",
"_release": "1.0.7", "_release": "1.0.8",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "v1.0.7", "tag": "v1.0.8",
"commit": "087c9ecdfca14f4a3faf45006203de08a8910995" "commit": "5cad377a1321656a2bdc65644b1ad26ab76f1ecb"
}, },
"_source": "git://github.com/PolymerElements/paper-slider.git", "_source": "git://github.com/PolymerElements/paper-slider.git",
"_target": "~1.0.3", "_target": "~1.0.3",

View file

@ -0,0 +1,28 @@
language: node_js
sudo: false
matrix:
include:
- node_js: stable
script: xvfb-run wct
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
- node_js: node
script:
- |
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
wct -s 'default'
fi
before_script:
- npm install web-component-tester
- npm install bower
- export PATH=$PWD/node_modules/.bin:$PATH
- bower install
env:
global:
- secure: W9pv3wK5AyI038GpPZpFo5yii72up1pTHM9yu8TI4th6Q/TiUQCa8GbjAMhUcbMDl3Y4i50WjckykSox+c506Zs5Pe5vDCaKpHT/iOHYqjIaQEDGGvvKWxSTJr82HY2taNhkH7seksg7oKq8dL7DCBLyKJUl03hGmRqZABjIw9fWjSNUb9PVdlZass5nJaqw954t76GYBWcQ71fntm8uCnSrQoviHEprvfwZMNnK0mhd79VmBohl83jpFU8FaYEWLc5IFY29u7McLxgynZBggwhGSrvdDrOYG4jtn26RNx4mNCcJGxejzadvf4K6H2S45SGnsCIjJRJbl8MV+ni18VqC/BuCF2J4k8QqSRtWi2mSq/l9DOgIiwViPRjPRxoK+a+/6qA7pQ1aMXBWWF4FjngvgoZHcY2J5FptbRltDtalrUSbUVmmKNoWwaJa4Sb5OopJdr0herGds946qzQKW1FLqkcDTtF6c4fZqK12WVEIXZLXiP9sV9+dBJDXT4oWzgjo2GHAiMEzV6Xk3oZ/RHmWJ34Bemy7M5zYKDHErLhD6/UXiA/tYlTqqgu/4Jdxs07ilWmaVd3kTYywRYuTzR4yO3xq8ElpEnpby2WobGiVCsuzQwOe4fWSvV4wS8TpSdigoGxYQ+FPrrbc7jhgRodyZP1xF/mTHlIvNmaTYYc=
- secure: xLLhaBejrIuYAxwQoFPsrvnBpeDVY8IYdThJ36fJnD4V0jpqS7m8b2rw5fYrtwWvmEAQlqJ20/hnjfp9kKXr6Qpkj2im9d0KWdw4xAyD2KxiG/u5pBn1Y+zE9iGjq+NGa58EJDNaxQSnaXmVnk55tyT9W3ailkiO/lEtaofXXXGqiW9Nxa9D0GtbbNWBypcoc7X/HXCcg5hVpdVjEFh3Y+nFWIdqJEO0V7oKujfb5yFhu5PRU7siTzdN+nLoPXPMlkBa3aWwPLdM1D9HKXN1jBX6dM9dH3oz20K/TCPpbO5u675vfuTT9iP9XuLy4LB/cl7S6bcopvhU5ipkQvLEieeq73EP1hz5vwdSWgleXkNhWBInhzeHLTI04M49ZxIc0NEay2Tvx9tQl5e8BT1/WglpjnHvqx/VoF7zkHRfWyWeObL6YyFVFiJ0Gz3ExJTUCruQRBen+g2Cqr1qwBN4bFPhgxzHW58ECdsDFvfpZT3I7h/wnCzNVOZx+A74nVwDpl6zg+/+GWpqZF2ILGbRDTcjp1A/eH+FMwnQccRLiBcXm4v4y8pFfaNzjRwswUQjnMV5KyIV+dSyQQAh9sBedFJjeWm1HSy3UXFZvyc6gQIG5GR5uGWkyxYHdCxBFMYFj2xmEzoLwF7omu5CXF0TUdYxb5hvUBMEqEEKIwte2VE=

View file

@ -0,0 +1,72 @@
<!--
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 :)
-->
# 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: [http://jsbin.com/cagaye](http://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 using the following syntax:
```markdown
(For a single issue)
Fixes #20
(For multiple issues)
Fixes #32, #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

@ -1,6 +1,6 @@
{ {
"name": "paper-slider", "name": "paper-slider",
"version": "1.0.7", "version": "1.0.8",
"description": "A material design-style slider", "description": "A material design-style slider",
"license": "http://polymer.github.io/LICENSE.txt", "license": "http://polymer.github.io/LICENSE.txt",
"authors": "The Polymer Authors", "authors": "The Polymer Authors",
@ -10,13 +10,12 @@
"slider", "slider",
"control" "control"
], ],
"main": [ "main": "paper-slider.html",
"paper-slider.html"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/PolymerElements/paper-slider.git" "url": "git://github.com/PolymerElements/paper-slider.git"
}, },
"ignore": [],
"dependencies": { "dependencies": {
"polymer": "Polymer/polymer#^1.0.0", "polymer": "Polymer/polymer#^1.0.0",
"paper-input": "PolymerElements/paper-input#^1.0.0", "paper-input": "PolymerElements/paper-input#^1.0.0",
@ -33,7 +32,7 @@
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0", "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
"test-fixture": "PolymerElements/test-fixture#^1.0.0", "test-fixture": "PolymerElements/test-fixture#^1.0.0",
"iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0", "iron-test-helpers": "polymerelements/iron-test-helpers#^1.0.0",
"web-component-tester": "*", "web-component-tester": "polymer/web-component-tester#^3.4.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
} }
} }

View file

@ -16,15 +16,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<script src="../../webcomponentsjs/webcomponents.js"></script> <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../paper-styles/demo-pages.html"> <link rel="import" href="../../paper-styles/demo-pages.html">
<link rel="import" href="../../paper-styles/color.html">
<link rel="import" href="../paper-slider.html"> <link rel="import" href="../paper-slider.html">
<style is="custom-style"> <style is="custom-style">
body { body {
padding: 40px; padding: 40px;
} }
paper-slider { paper-slider {
width: 100%; width: 100%;
} }
@ -63,7 +64,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</head> </head>
<body unresolved> <body unresolved>
<div class="vertical center-justified layout"> <div class="vertical-section-container">
<h4>Default</h4> <h4>Default</h4>
<div class="vertical-section"> <div class="vertical-section">
<div>Oxygen</div> <div>Oxygen</div>
@ -75,24 +76,24 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<div>Nitrogen</div> <div>Nitrogen</div>
<paper-slider value="78" secondary-progress="85"></paper-slider><br><br> <paper-slider value="78" secondary-progress="85"></paper-slider><br><br>
<div>Sprinkles</div> <div>Sprinkles</div>
<paper-slider disabled value="33" secondary-progress="66"></paper-slider> <paper-slider disabled value="33"></paper-slider>
</div> </div>
<h4>Editable</h4> <h4>Editable</h4>
<div class="vertical-section"> <div class="vertical-section">
<div class="center horizontal layout"> <div>
<div>R</div> <div>R</div>
<paper-slider class="red" value="23" max="255" editable></paper-slider> <paper-slider class="red" value="23" max="255" editable></paper-slider>
</div> </div>
<div class="center horizontal layout"> <div>
<div>G</div> <div>G</div>
<paper-slider class="green" value="183" max="255" editable></paper-slider> <paper-slider class="green" value="183" max="255" editable></paper-slider>
</div> </div>
<div class="center horizontal layout"> <div>
<div>B</div> <div>B</div>
<paper-slider class="blue" value="211" max="255" editable></paper-slider> <paper-slider class="blue" value="211" max="255" editable></paper-slider>
</div> </div>
<div class="center horizontal layout"> <div>
<div>&alpha;</div> <div>&alpha;</div>
<paper-slider max="1.0" step="0.01" editable></paper-slider> <paper-slider max="1.0" step="0.01" editable></paper-slider>
</div> </div>
@ -103,7 +104,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<div>Brightness</div><br> <div>Brightness</div><br>
<paper-slider pin value="20" class="orange"></paper-slider> <paper-slider pin value="20" class="orange"></paper-slider>
<div>Ratings: <span id="ratingsLabel" class="caption"></span></div><br> <div>Ratings: <span id="ratingsLabel" class="caption"></span></div><br>
<paper-slider id="ratings" pin snaps max="10" step="1" value="5" class="orange"></paper-slider> <paper-slider id="ratings" pin snaps max="10" max-markers="10" step="1" value="5" class="orange"></paper-slider>
<div>Grade: <span id="gradeLabel" class="caption"></span></div><br> <div>Grade: <span id="gradeLabel" class="caption"></span></div><br>
<paper-slider id="grade" pin value="20" secondary-progress="70" class="blue"></paper-slider> <paper-slider id="grade" pin value="20" secondary-progress="70" class="blue"></paper-slider>
</div> </div>
@ -122,11 +123,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
document.querySelector('#gradeLabel').textContent = grade.value + " (" + label + ")"; document.querySelector('#gradeLabel').textContent = grade.value + " (" + label + ")";
}); });
var test = document.querySelector("#test");
test.addEventListener('value-changed', function(e) {
console.log(e);
});
</script> </script>
</body> </body>

View file

@ -67,7 +67,9 @@ Custom property | Description | Default
<template strip-whitespace> <template strip-whitespace>
<style> <style>
:host { :host {
display: inline-block; @apply(--layout);
@apply(--layout-justified);
@apply(--layout-center);
width: 200px; width: 200px;
cursor: default; cursor: default;
-webkit-user-select: none; -webkit-user-select: none;
@ -88,8 +90,10 @@ Custom property | Description | Default
#sliderContainer { #sliderContainer {
position: relative; position: relative;
width: calc(100% - 32px); width: 100%;
height: 32px; height: calc(30px + var(--paper-slider-height, 2px));
margin-left: calc(15px + var(--paper-slider-height, 2px)/2);
margin-right: calc(15px + var(--paper-slider-height, 2px)/2);
} }
#sliderContainer:focus { #sliderContainer:focus {
@ -97,70 +101,67 @@ Custom property | Description | Default
} }
#sliderContainer.editable { #sliderContainer.editable {
float: left; margin-top: 12px;
width: calc(100% - 72px); margin-bottom: 12px;
margin: 12px 0;
} }
.bar-container { .bar-container {
position: absolute; position: absolute;
top: 0; top: 0;
left: 16px; bottom: 0;
height: 100%; left: 0;
width: 100%; right: 0;
overflow: hidden; overflow: hidden;
} }
.ring > .bar-container { .ring > .bar-container {
left: 20px; left: calc(5px + var(--paper-slider-height, 2px)/2);
width: calc(100% - 4px);
transition: left 0.18s ease, width 0.18s ease; transition: left 0.18s ease, width 0.18s ease;
} }
.ring.expand:not(.pin) > .bar-container {
left: 30px;
width: calc(100% - 14px);
}
.ring.expand.dragging > .bar-container { .ring.expand.dragging > .bar-container {
transition: none; transition: none;
} }
.ring.expand:not(.pin) > .bar-container {
left: calc(15px + var(--paper-slider-height, 2px)/2);
}
#sliderBar { #sliderBar {
position: absolute; padding: 15px 0;
top: 15px;
left: 0;
width: 100%; width: 100%;
padding: 8px 0;
margin: -8px 0;
background-color: var(--paper-slider-bar-color, transparent); background-color: var(--paper-slider-bar-color, transparent);
--paper-progress-height: var(--paper-slider-height, 2px); --paper-progress-height: var(--paper-slider-height, 2px);
} }
.ring #sliderBar { .ring #sliderBar {
left: -4px; margin-left: calc(-5px - var(--paper-slider-height, 2px)/2);
width: calc(100% + 4px); width: calc(100% + 5px + var(--paper-slider-height, 2px)/2);
} }
.ring.expand:not(.pin) #sliderBar { .ring.expand:not(.pin) #sliderBar {
left: -14px; margin-left: calc(-15px - var(--paper-slider-height, 2px)/2);
width: calc(100% + 14px); width: calc(100% + 15px + var(--paper-slider-height, 2px)/2);
} }
.slider-markers { .slider-markers {
position: absolute; position: absolute;
top: 15px; top: calc(14px + var(--paper-slider-height,2px)/2);
left: 15px; height: var(--paper-slider-height, 2px);
height: 2px; left: 0;
width: calc(100% + 2px); right: -1px;
box-sizing: border-box; box-sizing: border-box;
pointer-events: none; pointer-events: none;
@apply(--layout-horizontal);
} }
.slider-marker {
@apply(--layout-flex);
}
.slider-markers::after, .slider-markers::after,
.slider-marker::after { .slider-marker::after {
content: ""; content: "";
display: block; display: block;
margin-left: -1px;
width: 2px; width: 2px;
height: 2px; height: 2px;
border-radius: 50%; border-radius: 50%;
@ -168,15 +169,12 @@ Custom property | Description | Default
} }
#sliderKnob { #sliderKnob {
@apply(--layout-center-justified);
@apply(--layout-center);
@apply(--layout-horizontal);
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
width: 32px; margin-left: calc(-15px - var(--paper-slider-height, 2px)/2);
height: 32px; width: calc(30px + var(--paper-slider-height, 2px));
height: calc(30px + var(--paper-slider-height, 2px));
} }
.transiting > #sliderKnob { .transiting > #sliderKnob {
@ -197,20 +195,22 @@ Custom property | Description | Default
} }
#sliderKnobInner { #sliderKnobInner {
width: 12px; margin: 10px;
height: 12px; width: calc(100% - 20px);
height: calc(100% - 20px);
border-radius: 50%; border-radius: 50%;
background-color: var(--paper-slider-knob-color, --google-blue-700); background-color: var(--paper-slider-knob-color, --google-blue-700);
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
transition-property: height, width, background-color, border; transition-property: margin, height, width, background-color, border;
transition-duration: 0.1s; transition-duration: 0.1s;
transition-timing-function: ease; transition-timing-function: ease;
} }
.expand:not(.pin) > #sliderKnob > #sliderKnobInner { .expand:not(.pin) > #sliderKnob > #sliderKnobInner {
margin: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -231,10 +231,10 @@ Custom property | Description | Default
content: ""; content: "";
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 50%;
margin-left: -13px;
width: 26px; width: 26px;
height: 26px; height: 26px;
margin-left: 3px;
border-radius: 50% 50% 50% 0; border-radius: 50% 50% 50% 0;
-webkit-transform: rotate(-45deg) scale(0) translate(0); -webkit-transform: rotate(-45deg) scale(0) translate(0);
@ -260,7 +260,8 @@ Custom property | Description | Default
content: attr(value); content: attr(value);
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 50%;
margin-left: -16px;
width: 32px; width: 32px;
height: 26px; height: 26px;
text-align: center; text-align: center;
@ -279,7 +280,6 @@ Custom property | Description | Default
/* paper-input */ /* paper-input */
.slider-input { .slider-input {
width: 50px; width: 50px;
float: right;
overflow: hidden; overflow: hidden;
--paper-input-container-input: { --paper-input-container-input: {
text-align: center; text-align: center;
@ -291,9 +291,14 @@ Custom property | Description | Default
pointer-events: none; pointer-events: none;
} }
.disabled > #sliderKnob {
top: 2px;
margin-left: calc(-13px - var(--paper-slider-height, 2px)/2);
width: calc(26px + var(--paper-slider-height, 2px));
height: calc(26px + var(--paper-slider-height, 2px));
}
.disabled > #sliderKnob > #sliderKnobInner { .disabled > #sliderKnob > #sliderKnobInner {
width: 8px;
height: 8px;
background-color: var(--paper-slider-disabled-knob-color, --google-grey-500); background-color: var(--paper-slider-disabled-knob-color, --google-grey-500);
} }
@ -326,20 +331,19 @@ Custom property | Description | Default
</div> </div>
<template is="dom-if" if="[[snaps]]"> <template is="dom-if" if="[[snaps]]">
<div class="slider-markers horizontal layout"> <div class="slider-markers">
<template is="dom-repeat" items="[[markers]]"> <template is="dom-repeat" items="[[markers]]">
<div class="slider-marker flex"></div> <div class="slider-marker"></div>
</template> </template>
</div> </div>
</template> </template>
<div id="sliderKnob" <div id="sliderKnob"
class="center-justified center horizontal layout"
on-down="_knobdown" on-down="_knobdown"
on-up="_resetKnob" on-up="_resetKnob"
on-track="_onTrack" on-track="_onTrack"
on-transitionend="_knobTransitionEnd"> on-transitionend="_knobTransitionEnd">
<div id="sliderKnobInner" value$="[[pinValue]]"></div> <div id="sliderKnobInner" value$="[[immediateValue]]"></div>
</div> </div>
</div> </div>
<template is="dom-if" if="[[editable]]"> <template is="dom-if" if="[[editable]]">
@ -538,7 +542,6 @@ Custom property | Description | Default
_positionKnob: function(ratio) { _positionKnob: function(ratio) {
this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio))); this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio)));
this._setPinValue(this.immediateValue);
this._setRatio(this._calcRatio(this.immediateValue)); this._setRatio(this._calcRatio(this.immediateValue));
this.$.sliderKnob.style.left = (this.ratio * 100) + '%'; this.$.sliderKnob.style.left = (this.ratio * 100) + '%';
@ -587,7 +590,6 @@ Custom property | Description | Default
// update knob's position // update knob's position
var translateX = ((this._calcRatio(immediateValue) * this._w) - this._startx); var translateX = ((this._calcRatio(immediateValue) * this._w) - this._startx);
this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob); this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob);
this._setPinValue(immediateValue);
}, },
_trackEnd: function() { _trackEnd: function() {
@ -602,9 +604,6 @@ Custom property | Description | Default
this.fire('change'); this.fire('change');
}, },
_setPinValue: function (value) {
this.pinValue = value;
},
_knobdown: function(event) { _knobdown: function(event) {
this._expandKnob(); this._expandKnob();
@ -651,12 +650,14 @@ Custom property | Description | Default
}, },
_maxMarkersChanged: function(maxMarkers) { _maxMarkersChanged: function(maxMarkers) {
var l = (this.max - this.min) / this.step; if (!this.snaps) {
if (!this.snaps && l > maxMarkers) {
this._setMarkers([]); this._setMarkers([]);
} else {
this._setMarkers(new Array(l));
} }
var steps = Math.floor((this.max - this.min) / this.step);
if (steps > maxMarkers) {
steps = maxMarkers;
}
this._setMarkers(new Array(steps));
}, },
_mergeClasses: function(classes) { _mergeClasses: function(classes) {

View file

@ -16,11 +16,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script> <script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script> <script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../paper-slider.html"> <link rel="import" href="../paper-slider.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head> </head>
<body> <body>
@ -45,9 +43,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(slider.getAttribute('aria-valuenow'), slider.value); assert.equal(slider.getAttribute('aria-valuenow'), slider.value);
}); });
test('interacting without keyboard causes no ripple', function() { test('ripple is added after keyboard event on knob', function() {
assert.isFalse(slider.hasRipple());
MockInteractions.down(slider.$.sliderKnob); MockInteractions.down(slider.$.sliderKnob);
assert.isTrue(slider.hasRipple()); assert.isTrue(slider.hasRipple());
});
test('interacting without keyboard causes no ripple', function() {
MockInteractions.focus(slider);
MockInteractions.down(slider.$.sliderKnob);
var ripple = slider.getRipple(); var ripple = slider.getRipple();
assert.equal(ripple.offsetHeight, 0); assert.equal(ripple.offsetHeight, 0);
assert.equal(ripple.offsetWidth, 0); assert.equal(ripple.offsetWidth, 0);
@ -56,7 +60,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('interacting with keyboard causes ripple', function() { test('interacting with keyboard causes ripple', function() {
MockInteractions.focus(slider); MockInteractions.focus(slider);
MockInteractions.pressSpace(slider.$.sliderKnob); MockInteractions.pressSpace(slider.$.sliderKnob);
assert.isTrue(slider.hasRipple());
var ripple = slider.getRipple(); var ripple = slider.getRipple();
assert.isAbove(ripple.offsetHeight, 0); assert.isAbove(ripple.offsetHeight, 0);
assert.isAbove(ripple.offsetWidth, 0); assert.isAbove(ripple.offsetWidth, 0);

View file

@ -16,11 +16,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script> <script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="../../iron-test-helpers/mock-interactions.js"></script> <script src="../../iron-test-helpers/mock-interactions.js"></script>
<link rel="import" href="../paper-slider.html"> <link rel="import" href="../paper-slider.html">
<link rel="import" href="../../test-fixture/test-fixture.html">
</head> </head>
<body> <body>
@ -181,14 +179,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('value should notify', function(done) { test('value should notify', function(done) {
var targetValue = 10; var targetValue = 10;
slider.addEventListener('value-changed', function(e) { slider.addEventListener('value-changed', onValueChanged);
assert.equal(e.detail.value, targetValue);
done();
});
slider.min = 0; slider.min = 0;
slider.max = 100; slider.max = 100;
slider.value = targetValue; slider.value = targetValue;
function onValueChanged(e) {
assert.equal(e.detail.value, targetValue);
done();
slider.removeEventListener('value-changed', onValueChanged);
}
}); });
test('immediateValue should notify', function(done) { test('immediateValue should notify', function(done) {
@ -199,7 +200,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(slider.immediateValue, targetValue); assert.equal(slider.immediateValue, targetValue);
done(); done();
}); });
var cursor = MockInteractions.topLeftOfNode(slider.$.sliderBar); var cursor = MockInteractions.topLeftOfNode(slider.$.sliderBar);
cursor.x += slider.$.sliderBar.getBoundingClientRect().width * targetValue/100; cursor.x += slider.$.sliderBar.getBoundingClientRect().width * targetValue/100;
@ -208,6 +209,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
MockInteractions.down(slider.$.sliderBar, cursor); MockInteractions.down(slider.$.sliderBar, cursor);
}); });
test('max markers', function(done) {
slider.min = 0;
slider.max = 100;
slider.snap = true;
slider.step = 4;
slider.maxMarkers = 10;
flush(function() {
assert.equal(slider.markers.length, 10);
done();
});
});
}); });
</script> </script>