added tests with paper-slider
This commit is contained in:
22
bower_components/paper-slider/.bower.json
vendored
Normal file
22
bower_components/paper-slider/.bower.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "paper-slider",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"font-roboto": "Polymer/font-roboto#^0.5.0",
|
||||
"paper-input": "Polymer/paper-input#^0.5.0",
|
||||
"paper-progress": "Polymer/paper-progress#^0.5.0",
|
||||
"core-a11y-keys": "Polymer/core-a11y-keys#^0.5.0"
|
||||
},
|
||||
"version": "0.5.2",
|
||||
"homepage": "https://github.com/Polymer/paper-slider",
|
||||
"_release": "0.5.2",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "0.5.2",
|
||||
"commit": "e08291c22765ce2e5794e8f5b1ea2ea4620ac61e"
|
||||
},
|
||||
"_source": "git://github.com/Polymer/paper-slider.git",
|
||||
"_target": "~0.5.2",
|
||||
"_originalSource": "Polymer/paper-slider",
|
||||
"_direct": true
|
||||
}
|
||||
4
bower_components/paper-slider/README.md
vendored
Normal file
4
bower_components/paper-slider/README.md
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
paper-slider
|
||||
============
|
||||
|
||||
See the [component page](http://www.polymer-project.org/docs/elements/paper-elements.html#paper-slider) for more information.
|
||||
11
bower_components/paper-slider/bower.json
vendored
Normal file
11
bower_components/paper-slider/bower.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "paper-slider",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"font-roboto": "Polymer/font-roboto#^0.5.0",
|
||||
"paper-input": "Polymer/paper-input#^0.5.0",
|
||||
"paper-progress": "Polymer/paper-progress#^0.5.0",
|
||||
"core-a11y-keys": "Polymer/core-a11y-keys#^0.5.0"
|
||||
},
|
||||
"version": "0.5.2"
|
||||
}
|
||||
145
bower_components/paper-slider/demo.html
vendored
Normal file
145
bower_components/paper-slider/demo.html
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
<!--
|
||||
@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
|
||||
-->
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>paper-slider</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
|
||||
<link rel="import" href="paper-slider.html">
|
||||
<link rel="import" href="../font-roboto/roboto.html">
|
||||
|
||||
<style shim-shadowdom>
|
||||
|
||||
body {
|
||||
font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
|
||||
margin: 0;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
paper-slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
section {
|
||||
max-width: 1000px;
|
||||
padding: 20px 0;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
section > div {
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.yellow-slider paper-slider::shadow #sliderKnobInner,
|
||||
.yellow-slider paper-slider::shadow #sliderBar::shadow #activeProgress {
|
||||
background-color: #f4b400;
|
||||
}
|
||||
|
||||
.green-slider paper-slider::shadow #sliderKnobInner,
|
||||
.green-slider paper-slider::shadow #sliderKnobInner::before,
|
||||
.green-slider paper-slider::shadow #sliderBar::shadow #activeProgress {
|
||||
background-color: #0f9d58;
|
||||
}
|
||||
|
||||
#ratingsLabel {
|
||||
padding-left: 12px;
|
||||
color: #a0a0a0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<section class="yellow-slider">
|
||||
|
||||
<div>Music, video, games & other media</div>
|
||||
<paper-slider value="50"></paper-slider>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div>Notifications</div>
|
||||
<paper-slider value="50"></paper-slider>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div>Alarms</div>
|
||||
<paper-slider value="80"></paper-slider>
|
||||
|
||||
</section>
|
||||
|
||||
<br>
|
||||
|
||||
<section>
|
||||
|
||||
<div center horizontal layout>
|
||||
<div>R</div>
|
||||
<paper-slider value="23" max="255" editable></paper-slider>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div center horizontal layout>
|
||||
<div>G</div>
|
||||
<paper-slider value="183" max="255" editable></paper-slider>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<div center horizontal layout>
|
||||
<div>B</div>
|
||||
<paper-slider value="211" max="255" editable></paper-slider>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<br>
|
||||
|
||||
<section class="green-slider">
|
||||
|
||||
<div>Brightness</div>
|
||||
<br>
|
||||
<paper-slider pin value="50"></paper-slider>
|
||||
|
||||
</section>
|
||||
|
||||
<br>
|
||||
|
||||
<section class="green-slider">
|
||||
|
||||
<div>
|
||||
<span>Ratings</span><span id="ratingsLabel"></span>
|
||||
</div>
|
||||
<br>
|
||||
<paper-slider id="ratings" pin snaps max="10" step="1" value="5"></paper-slider>
|
||||
|
||||
</section>
|
||||
|
||||
<script>
|
||||
|
||||
var ratings = document.querySelector('#ratings');
|
||||
ratings.addEventListener('core-change', function() {
|
||||
document.querySelector('#ratingsLabel').textContent = ratings.value;
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
bower_components/paper-slider/index.html
vendored
Normal file
22
bower_components/paper-slider/index.html
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
<link rel="import" href="../core-component-page/core-component-page.html">
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<core-component-page></core-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
20
bower_components/paper-slider/metadata.html
vendored
Normal file
20
bower_components/paper-slider/metadata.html
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<x-meta id="paper-slider" label="Slider" group="Paper">
|
||||
|
||||
<template>
|
||||
<paper-slider></paper-slider>
|
||||
</template>
|
||||
|
||||
<template id="imports">
|
||||
<link rel="import" href="paper-slider.html">
|
||||
</template>
|
||||
|
||||
</x-meta>
|
||||
239
bower_components/paper-slider/paper-slider.css
vendored
Normal file
239
bower_components/paper-slider/paper-slider.css
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
:host {
|
||||
display: inline-block;
|
||||
width: 200px;
|
||||
cursor: default;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
:host(:focus) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#sliderContainer {
|
||||
position: relative;
|
||||
width: calc(100% - 32px);
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
#sliderContainer.editable {
|
||||
float: left;
|
||||
width: calc(100% - 72px);
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.bar-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 16px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ring > .bar-container {
|
||||
left: 20px;
|
||||
width: calc(100% - 4px);
|
||||
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 {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
#sliderBar {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 0;
|
||||
height: 2px;
|
||||
width: 100%;
|
||||
padding: 8px 0;
|
||||
margin: -8px 0;
|
||||
}
|
||||
|
||||
.ring #sliderBar {
|
||||
left: -4px;
|
||||
width: calc(100% + 4px);
|
||||
}
|
||||
|
||||
.ring.expand:not(.pin) #sliderBar {
|
||||
left: -14px;
|
||||
width: calc(100% + 14px);
|
||||
}
|
||||
|
||||
.slider-markers {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
height: 2px;
|
||||
width: calc(100% + 2px);
|
||||
box-sizing: border-box;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.slider-markers::after, .slider-marker::after {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 2px;
|
||||
height: 2px;
|
||||
border-radius: 50%;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#sliderBar::shadow #activeProgress {
|
||||
background-color: #3f51b5;
|
||||
}
|
||||
|
||||
.transiting #sliderBar::shadow #activeProgress {
|
||||
transition: -webkit-transform 0.08s ease;
|
||||
transition: transform 0.08s ease;
|
||||
}
|
||||
|
||||
#sliderKnob {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.transiting > #sliderKnob {
|
||||
transition: left 0.08s ease;
|
||||
}
|
||||
|
||||
#sliderKnob:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#sliderKnob.dragging {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.snaps > #sliderKnob.dragging {
|
||||
transition: -webkit-transform 0.08s ease;
|
||||
transition: transform 0.08s ease;
|
||||
}
|
||||
|
||||
#sliderKnobInner {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
border-radius: 50%;
|
||||
background-color: #3f51b5;
|
||||
/* FIXME(ffu): can't use the following. https://github.com/Polymer/platform/issues/53 */
|
||||
/* transition-property: height, width, background-color, border;
|
||||
transition-duration: 0.1s;
|
||||
transition-timing-function: ease; */
|
||||
transition: height 0.18s ease, width 0.18s ease;
|
||||
}
|
||||
|
||||
.expand:not(.pin) > #sliderKnob > #sliderKnobInner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
-webkit-transform: translateZ(0);
|
||||
transform: translateZ(0);
|
||||
}
|
||||
|
||||
.ring > #sliderKnob > #sliderKnobInner {
|
||||
background-color: transparent;
|
||||
border: 2px solid #c8c8c8;
|
||||
}
|
||||
|
||||
#sliderKnobInner::before {
|
||||
background-color: #3f51b5;
|
||||
}
|
||||
|
||||
.pin > #sliderKnob > #sliderKnobInner::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
margin-left: 3px;
|
||||
border-radius: 50% 50% 50% 0;
|
||||
-webkit-transform: rotate(-45deg) scale(0) translate(0);
|
||||
transform: rotate(-45deg) scale(0) translate(0);
|
||||
}
|
||||
|
||||
#sliderKnobInner::before, #sliderKnobInner::after {
|
||||
transition: -webkit-transform .2s ease, background-color .18s ease;
|
||||
transition: transform .2s ease, background-color .18s ease;
|
||||
}
|
||||
|
||||
.pin.ring > #sliderKnob > #sliderKnobInner::before {
|
||||
background-color: #c8c8c8;
|
||||
}
|
||||
|
||||
.pin.expand > #sliderKnob > #sliderKnobInner::before {
|
||||
-webkit-transform: rotate(-45deg) scale(1) translate(17px, -17px);
|
||||
transform: rotate(-45deg) scale(1) translate(17px, -17px);
|
||||
}
|
||||
|
||||
.pin > #sliderKnob > #sliderKnobInner::after {
|
||||
content: attr(value);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 32px;
|
||||
height: 26px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
-webkit-transform: scale(0) translate(0);
|
||||
transform: scale(0) translate(0);
|
||||
}
|
||||
|
||||
.pin.expand > #sliderKnob > #sliderKnobInner::after {
|
||||
-webkit-transform: scale(1) translate(0, -17px);
|
||||
transform: scale(1) translate(0, -17px);
|
||||
}
|
||||
|
||||
/* editable: paper-input */
|
||||
.slider-input {
|
||||
width: 40px;
|
||||
float: right;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.slider-input::shadow input {
|
||||
/* FIXME(ffu): should one be able set text-align directly on paper-input? */
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* disabled state */
|
||||
#sliderContainer.disabled {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.disabled > #sliderKnob > #sliderKnobInner {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
background-color: #c8c8c8;
|
||||
}
|
||||
|
||||
.disabled.ring > #sliderKnob > #sliderKnobInner {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#sliderContainer.disabled #sliderBar::shadow #activeProgress {
|
||||
background-color: #c8c8c8;
|
||||
}
|
||||
356
bower_components/paper-slider/paper-slider.html
vendored
Normal file
356
bower_components/paper-slider/paper-slider.html
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
<!--
|
||||
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
|
||||
-->
|
||||
|
||||
<!--
|
||||
`paper-slider` allows user to select a value from a range of values by
|
||||
moving the slider thumb. The interactive nature of the slider makes it a
|
||||
great choice for settings that reflect intensity levels, such as volume,
|
||||
brightness, or color saturation.
|
||||
|
||||
Example:
|
||||
|
||||
<paper-slider></paper-slider>
|
||||
|
||||
Use `min` and `max` to specify the slider range. Default is 0 to 100.
|
||||
|
||||
Example:
|
||||
|
||||
<paper-slider min="10" max="200" value="110"></paper-slider>
|
||||
|
||||
Styling slider:
|
||||
|
||||
To change the slider progress bar color:
|
||||
|
||||
paper-slider::shadow #sliderBar::shadow #activeProgress {
|
||||
background-color: #0f9d58;
|
||||
}
|
||||
|
||||
To change the slider knob color:
|
||||
|
||||
paper-slider::shadow #sliderKnobInner {
|
||||
background-color: #0f9d58;
|
||||
}
|
||||
|
||||
To change the slider pin color:
|
||||
|
||||
paper-slider::shadow #sliderKnobInner::before {
|
||||
background-color: #0f9d58;
|
||||
}
|
||||
|
||||
To change the slider pin's font color:
|
||||
|
||||
paper-slider::shadow #sliderKnob > #sliderKnobInner::after {
|
||||
color: #0f9d58
|
||||
}
|
||||
|
||||
To change the slider secondary progress bar color:
|
||||
|
||||
paper-slider::shadow #sliderBar::shadow #secondaryProgress {
|
||||
background-color: #0f9d58;
|
||||
}
|
||||
|
||||
@group Paper Elements
|
||||
@element paper-slider
|
||||
@extends core-range
|
||||
@homepage github.io
|
||||
-->
|
||||
|
||||
<link rel="import" href="../core-a11y-keys/core-a11y-keys.html">
|
||||
<link rel="import" href="../paper-progress/paper-progress.html">
|
||||
<link rel="import" href="../paper-input/paper-input.html">
|
||||
|
||||
<polymer-element name="paper-slider" extends="core-range" attributes="snaps pin disabled secondaryProgress editable immediateValue" role="slider" tabindex="0" aria-valuemin="0" aria-valuemax="100">
|
||||
<template>
|
||||
|
||||
<link rel="stylesheet" href="paper-slider.css">
|
||||
|
||||
<template if="{{!disabled}}">
|
||||
<core-a11y-keys target="{{}}" keys="left down pagedown home" on-keys-pressed="{{decrementKey}}"></core-a11y-keys>
|
||||
<core-a11y-keys target="{{}}" keys="right up pageup end" on-keys-pressed="{{incrementKey}}"></core-a11y-keys>
|
||||
</template>
|
||||
|
||||
<div id="sliderContainer" class="{{ {disabled: disabled, pin: pin, snaps: snaps, ring: immediateValue <= min, expand: expand, dragging: dragging, transiting: transiting, editable: editable} | tokenList }}">
|
||||
|
||||
<div class="bar-container">
|
||||
<paper-progress id="sliderBar" aria-hidden="true" min="{{min}}" max="{{max}}" value="{{immediateValue}}" secondaryProgress="{{secondaryProgress}}"
|
||||
on-down="{{bardown}}" on-up="{{resetKnob}}"
|
||||
on-trackstart="{{trackStart}}" on-trackx="{{trackx}}" on-trackend="{{trackEnd}}"></paper-progress>
|
||||
</div>
|
||||
|
||||
<template if="{{snaps && !disabled}}">
|
||||
<div class="slider-markers" horizontal layout>
|
||||
<template repeat="{{markers}}">
|
||||
<div flex class="slider-marker"></div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div id="sliderKnob" on-down="{{knobdown}}" on-up="{{resetKnob}}"
|
||||
on-trackstart="{{trackStart}}" on-trackx="{{trackx}}" on-trackend="{{trackEnd}}"
|
||||
on-transitionend="{{knobTransitionEnd}}"
|
||||
center-justified center horizontal layout>
|
||||
|
||||
<div id="sliderKnobInner" value="{{immediateValue}}"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<template if="{{editable}}">
|
||||
<paper-input id="input" class="slider-input" value="{{immediateValue}}" disabled?="{{disabled}}" on-change="{{inputChange}}"></paper-input>
|
||||
</template>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
|
||||
Polymer('paper-slider', {
|
||||
|
||||
/**
|
||||
* Fired when the slider's value changes.
|
||||
*
|
||||
* @event core-change
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired when the slider's immediateValue changes.
|
||||
*
|
||||
* @event immediate-value-change
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired when the slider's value changes due to user interaction.
|
||||
*
|
||||
* Changes to the slider's value due to changes in an underlying
|
||||
* bound variable will not trigger this event.
|
||||
*
|
||||
* @event change
|
||||
*/
|
||||
|
||||
/**
|
||||
* If true, the slider thumb snaps to tick marks evenly spaced based
|
||||
* on the `step` property value.
|
||||
*
|
||||
* @attribute snaps
|
||||
* @type boolean
|
||||
* @default false
|
||||
*/
|
||||
snaps: false,
|
||||
|
||||
/**
|
||||
* If true, a pin with numeric value label is shown when the slider thumb
|
||||
* is pressed. Use for settings for which users need to know the exact
|
||||
* value of the setting.
|
||||
*
|
||||
* @attribute pin
|
||||
* @type boolean
|
||||
* @default false
|
||||
*/
|
||||
pin: false,
|
||||
|
||||
/**
|
||||
* If true, this slider is disabled. A disabled slider cannot be tapped
|
||||
* or dragged to change the slider value.
|
||||
*
|
||||
* @attribute disabled
|
||||
* @type boolean
|
||||
* @default false
|
||||
*/
|
||||
disabled: false,
|
||||
|
||||
/**
|
||||
* The number that represents the current secondary progress.
|
||||
*
|
||||
* @attribute secondaryProgress
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
secondaryProgress: 0,
|
||||
|
||||
/**
|
||||
* If true, an input is shown and user can use it to set the slider value.
|
||||
*
|
||||
* @attribute editable
|
||||
* @type boolean
|
||||
* @default false
|
||||
*/
|
||||
editable: false,
|
||||
|
||||
/**
|
||||
* The immediate value of the slider. This value is updated while the user
|
||||
* is dragging the slider.
|
||||
*
|
||||
* @attribute immediateValue
|
||||
* @type number
|
||||
* @default 0
|
||||
*/
|
||||
|
||||
maxMarkers: 100,
|
||||
|
||||
observe: {
|
||||
'step snaps': 'update'
|
||||
},
|
||||
|
||||
ready: function() {
|
||||
this.update();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.positionKnob(this.calcRatio(this.value));
|
||||
this.updateMarkers();
|
||||
},
|
||||
|
||||
minChanged: function() {
|
||||
this.update();
|
||||
this.setAttribute('aria-valuemin', this.min);
|
||||
},
|
||||
|
||||
maxChanged: function() {
|
||||
this.update();
|
||||
this.setAttribute('aria-valuemax', this.max);
|
||||
},
|
||||
|
||||
valueChanged: function() {
|
||||
this.update();
|
||||
this.setAttribute('aria-valuenow', this.value);
|
||||
this.fire('core-change');
|
||||
},
|
||||
|
||||
disabledChanged: function() {
|
||||
if (this.disabled) {
|
||||
this.removeAttribute('tabindex');
|
||||
} else {
|
||||
this.tabIndex = 0;
|
||||
}
|
||||
},
|
||||
|
||||
immediateValueChanged: function() {
|
||||
if (!this.dragging) {
|
||||
this.value = this.immediateValue;
|
||||
}
|
||||
this.fire('immediate-value-change');
|
||||
},
|
||||
|
||||
expandKnob: function() {
|
||||
this.expand = true;
|
||||
},
|
||||
|
||||
resetKnob: function() {
|
||||
this.expandJob && this.expandJob.stop();
|
||||
this.expand = false;
|
||||
},
|
||||
|
||||
positionKnob: function(ratio) {
|
||||
this.immediateValue = this.calcStep(this.calcKnobPosition(ratio)) || 0;
|
||||
this._ratio = this.snaps ? this.calcRatio(this.immediateValue) : ratio;
|
||||
this.$.sliderKnob.style.left = this._ratio * 100 + '%';
|
||||
},
|
||||
|
||||
inputChange: function() {
|
||||
this.value = this.$.input.value;
|
||||
this.fire('change');
|
||||
},
|
||||
|
||||
calcKnobPosition: function(ratio) {
|
||||
return (this.max - this.min) * ratio + this.min;
|
||||
},
|
||||
|
||||
trackStart: function(e) {
|
||||
this._w = this.$.sliderBar.offsetWidth;
|
||||
this._x = this._ratio * this._w;
|
||||
this._startx = this._x || 0;
|
||||
this._minx = - this._startx;
|
||||
this._maxx = this._w - this._startx;
|
||||
this.$.sliderKnob.classList.add('dragging');
|
||||
this.dragging = true;
|
||||
e.preventTap();
|
||||
},
|
||||
|
||||
trackx: function(e) {
|
||||
var x = Math.min(this._maxx, Math.max(this._minx, e.dx));
|
||||
this._x = this._startx + x;
|
||||
this.immediateValue = this.calcStep(
|
||||
this.calcKnobPosition(this._x / this._w)) || 0;
|
||||
var s = this.$.sliderKnob.style;
|
||||
s.transform = s.webkitTransform = 'translate3d(' + (this.snaps ?
|
||||
(this.calcRatio(this.immediateValue) * this._w) - this._startx : x) + 'px, 0, 0)';
|
||||
},
|
||||
|
||||
trackEnd: function() {
|
||||
var s = this.$.sliderKnob.style;
|
||||
s.transform = s.webkitTransform = '';
|
||||
this.$.sliderKnob.classList.remove('dragging');
|
||||
this.dragging = false;
|
||||
this.resetKnob();
|
||||
this.value = this.immediateValue;
|
||||
this.fire('change');
|
||||
},
|
||||
|
||||
knobdown: function(e) {
|
||||
e.preventDefault();
|
||||
this.expandKnob();
|
||||
},
|
||||
|
||||
bardown: function(e) {
|
||||
e.preventDefault();
|
||||
this.transiting = true;
|
||||
this._w = this.$.sliderBar.offsetWidth;
|
||||
var rect = this.$.sliderBar.getBoundingClientRect();
|
||||
var ratio = (e.x - rect.left) / this._w;
|
||||
this.positionKnob(ratio);
|
||||
this.expandJob = this.job(this.expandJob, this.expandKnob, 60);
|
||||
this.fire('change');
|
||||
},
|
||||
|
||||
knobTransitionEnd: function(e) {
|
||||
if (e.target === this.$.sliderKnob) {
|
||||
this.transiting = false;
|
||||
}
|
||||
},
|
||||
|
||||
updateMarkers: function() {
|
||||
this.markers = [];
|
||||
var l = (this.max - this.min) / this.step;
|
||||
if (!this.snaps && l > this.maxMarkers) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < l; i++) {
|
||||
this.markers.push('');
|
||||
}
|
||||
},
|
||||
|
||||
increment: function() {
|
||||
this.value = this.clampValue(this.value + this.step);
|
||||
},
|
||||
|
||||
decrement: function() {
|
||||
this.value = this.clampValue(this.value - this.step);
|
||||
},
|
||||
|
||||
incrementKey: function(ev, keys) {
|
||||
if (keys.key === "end") {
|
||||
this.value = this.max;
|
||||
} else {
|
||||
this.increment();
|
||||
}
|
||||
this.fire('change');
|
||||
},
|
||||
|
||||
decrementKey: function(ev, keys) {
|
||||
if (keys.key === "home") {
|
||||
this.value = this.min;
|
||||
} else {
|
||||
this.decrement();
|
||||
}
|
||||
this.fire('change');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</polymer-element>
|
||||
Reference in New Issue
Block a user