mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
restore slider changes
This commit is contained in:
parent
1a84e71a95
commit
bbf0b4d402
2 changed files with 410 additions and 397 deletions
|
@ -103,7 +103,7 @@ Custom property | Description | Default
|
||||||
class="circle"
|
class="circle"
|
||||||
hidden$="[[!receivedFocusFromKeyboard]]">
|
hidden$="[[!receivedFocusFromKeyboard]]">
|
||||||
</paper-ripple>
|
</paper-ripple>
|
||||||
<div id="sliderKnobInner" value$="[[immediateValue]]"></div>
|
<div id="sliderKnobInner" value$="[[pinValue]]"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -311,6 +311,7 @@ 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) + '%';
|
||||||
|
@ -365,6 +366,7 @@ 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() {
|
||||||
|
@ -477,6 +479,9 @@ Custom property | Description | Default
|
||||||
this.decrement();
|
this.decrement();
|
||||||
}
|
}
|
||||||
this.fire('change');
|
this.fire('change');
|
||||||
|
},
|
||||||
|
_setPinValue: function (value) {
|
||||||
|
this.pinValue = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16782,7 +16782,7 @@ iron-selector:not(.narrow-layout) #main ::content [paper-drawer-toggle] {
|
||||||
</script>
|
</script>
|
||||||
<dom-module id="paper-slider" assetpath="bower_components/paper-slider/">
|
<dom-module id="paper-slider" assetpath="bower_components/paper-slider/">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/**
|
/**
|
||||||
@license
|
@license
|
||||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||||
|
@ -16804,20 +16804,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host(:not([disabled])) #sliderBar::shadow #activeProgress {
|
:host(:not([disabled])) #sliderBar {
|
||||||
background-color: var(--paper-slider-active-color, --google-blue-700);
|
--paper-progress-active-color: var(--paper-slider-active-color, --google-blue-700);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host(:not([disabled])) #sliderBar::shadow #secondaryProgress {
|
:host(:not([disabled])) #sliderBar {
|
||||||
background-color: var(--paper-slider-secondary-color, --google-blue-300);
|
--paper-progress-secondary-color: var(--paper-slider-secondary-color, --google-blue-300);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([disabled]) #sliderBar::shadow #activeProgress {
|
:host([disabled]) #sliderBar {
|
||||||
background-color: var(--paper-slider-disabled-active-color, --google-grey-500);
|
--paper-progress-active-color: var(--paper-slider-disabled-active-color, --google-grey-500);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host([disabled]) #sliderBar::shadow #secondaryProgress {
|
:host([disabled]) #sliderBar {
|
||||||
background-color: var(--paper-slider-disabled-secondary-color, --google-grey-300);
|
--paper-progress-secondary-color: var(--paper-slider-disabled-secondary-color, --google-grey-300);
|
||||||
}
|
}
|
||||||
|
|
||||||
:host(:focus) {
|
:host(:focus) {
|
||||||
|
@ -16901,11 +16901,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.transiting #sliderBar::shadow #activeProgress {
|
|
||||||
-webkit-transition: -webkit-transform 0.08s ease;
|
|
||||||
transition: transform 0.08s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
#sliderKnob {
|
#sliderKnob {
|
||||||
@apply(--layout-center-justified);
|
@apply(--layout-center-justified);
|
||||||
@apply(--layout-center);
|
@apply(--layout-center);
|
||||||
|
@ -16938,10 +16933,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
#sliderKnobInner {
|
#sliderKnobInner {
|
||||||
width: 12px;
|
width: 12px;
|
||||||
height: 12px;
|
height: 12px;
|
||||||
box-sizing: border-box;
|
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
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;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
transition-property: height, width, background-color, border;
|
transition-property: height, width, background-color, border;
|
||||||
transition-duration: 0.1s;
|
transition-duration: 0.1s;
|
||||||
transition-timing-function: ease;
|
transition-timing-function: ease;
|
||||||
|
@ -16950,13 +16947,14 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
.expand:not(.pin) > #sliderKnob > #sliderKnobInner {
|
.expand:not(.pin) > #sliderKnob > #sliderKnobInner {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
-webkit-transform: translateZ(0);
|
-webkit-transform: translateZ(0);
|
||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.ring > #sliderKnob > #sliderKnobInner {
|
.ring > #sliderKnob > #sliderKnobInner {
|
||||||
background-color: transparent;
|
background-color: var(--paper-slider-knob-start-color, transparent);
|
||||||
border: 2px solid #c8c8c8;
|
border: 2px solid var(--paper-slider-knob-start-border-color, #c8c8c8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#sliderKnobInner::before {
|
#sliderKnobInner::before {
|
||||||
|
@ -16972,6 +16970,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
height: 26px;
|
height: 26px;
|
||||||
margin-left: 3px;
|
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);
|
||||||
transform: rotate(-45deg) scale(0) translate(0);
|
transform: rotate(-45deg) scale(0) translate(0);
|
||||||
}
|
}
|
||||||
|
@ -16983,7 +16982,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
}
|
}
|
||||||
|
|
||||||
.pin.ring > #sliderKnob > #sliderKnobInner::before {
|
.pin.ring > #sliderKnob > #sliderKnobInner::before {
|
||||||
background-color: #c8c8c8;
|
background-color: var(--paper-slider-pin-start-color, #c8c8c8);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pin.expand > #sliderKnob > #sliderKnobInner::before {
|
.pin.expand > #sliderKnob > #sliderKnobInner::before {
|
||||||
|
@ -17001,6 +17000,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--paper-slider-font-color, #fff);
|
color: var(--paper-slider-font-color, #fff);
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
|
|
||||||
-webkit-transform: scale(0) translate(0);
|
-webkit-transform: scale(0) translate(0);
|
||||||
transform: scale(0) translate(0);
|
transform: scale(0) translate(0);
|
||||||
}
|
}
|
||||||
|
@ -17017,9 +17017,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slider-input::shadow input {
|
.slider-input {
|
||||||
/* FIXME(ffu): should one be able set text-align directly on paper-input? */
|
--paper-input-container-input: {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disabled state */
|
/* disabled state */
|
||||||
|
@ -17043,414 +17044,421 @@ paper-ripple {
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="sliderContainer" class$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]">
|
<div id="sliderContainer" class$="[[_getClassNames(disabled, pin, snaps, immediateValue, min, expand, dragging, transiting, editable)]]">
|
||||||
|
|
||||||
<div class="bar-container">
|
<div class="bar-container">
|
||||||
<paper-progress id="sliderBar" aria-hidden="true" min="[[min]]" max="[[max]]" step="[[step]]" value="[[immediateValue]]" secondary-progress="[[secondaryProgress]]" on-down="_bardown" on-up="_resetKnob" on-track="_onTrack">
|
<paper-progress class$="[[_getProgressClass(transiting)]]" id="sliderBar" aria-hidden="true" min="[[min]]" max="[[max]]" step="[[step]]" value="[[immediateValue]]" secondary-progress="[[secondaryProgress]]" on-down="_bardown" on-up="_resetKnob" on-track="_onTrack">
|
||||||
</paper-progress>
|
</paper-progress>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template is="dom-if" if="[[snaps]]">
|
<template is="dom-if" if="[[snaps]]">
|
||||||
<div class="slider-markers horizontal layout">
|
<div class="slider-markers horizontal layout">
|
||||||
<template is="dom-repeat" items="[[markers]]">
|
<template is="dom-repeat" items="[[markers]]">
|
||||||
<div class="slider-marker flex"></div>
|
<div class="slider-marker flex"></div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div id="sliderKnob" class="center-justified center horizontal layout" on-down="_knobdown" on-up="_resetKnob" on-track="_onTrack" on-transitionend="_knobTransitionEnd">
|
|
||||||
<paper-ripple id="ink" class="circle" center="" hidden$="[[!receivedFocusFromKeyboard]]"></paper-ripple>
|
|
||||||
<div id="sliderKnobInner" value$="[[pinValue]]"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template is="dom-if" if="[[editable]]">
|
<div id="sliderKnob" class="center-justified center horizontal layout" on-down="_knobdown" on-up="_resetKnob" on-track="_onTrack" on-transitionend="_knobTransitionEnd">
|
||||||
<paper-input id="input" class="slider-input" disabled$="[[disabled]]" on-change="_inputChange">
|
<paper-ripple center="" id="ink" class="circle" hidden$="[[!receivedFocusFromKeyboard]]">
|
||||||
</paper-input>
|
</paper-ripple>
|
||||||
</template>
|
<div id="sliderKnobInner" value$="[[pinValue]]"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template is="dom-if" if="[[editable]]">
|
||||||
|
<paper-input id="input" class="slider-input" disabled$="[[disabled]]" on-change="_inputChange" value="[[_fixForInput(immediateValue)]]">
|
||||||
|
</paper-input>
|
||||||
</template>
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
Polymer({
|
Polymer({
|
||||||
is: 'paper-slider',
|
is: 'paper-slider',
|
||||||
|
|
||||||
behaviors: [
|
behaviors: [
|
||||||
Polymer.IronA11yKeysBehavior,
|
Polymer.IronFormElementBehavior,
|
||||||
Polymer.PaperInkyFocusBehavior,
|
Polymer.PaperInkyFocusBehavior,
|
||||||
Polymer.IronFormElementBehavior,
|
Polymer.IronRangeBehavior
|
||||||
Polymer.IronRangeBehavior
|
],
|
||||||
],
|
|
||||||
|
|
||||||
properties: {
|
properties: {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the slider thumb snaps to tick marks evenly spaced based
|
* If true, the slider thumb snaps to tick marks evenly spaced based
|
||||||
* on the `step` property value.
|
* on the `step` property value.
|
||||||
*/
|
*/
|
||||||
snaps: {
|
snaps: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
notify: true
|
notify: true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, a pin with numeric value label is shown when the slider thumb
|
* 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
|
* is pressed. Use for settings for which users need to know the exact
|
||||||
* value of the setting.
|
* value of the setting.
|
||||||
*/
|
*/
|
||||||
pin: {
|
pin: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
notify: true
|
notify: true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number that represents the current secondary progress.
|
* The number that represents the current secondary progress.
|
||||||
*/
|
*/
|
||||||
secondaryProgress: {
|
secondaryProgress: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0,
|
value: 0,
|
||||||
notify: true,
|
notify: true,
|
||||||
observer: '_secondaryProgressChanged'
|
observer: '_secondaryProgressChanged'
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, an input is shown and user can use it to set the slider value.
|
* If true, an input is shown and user can use it to set the slider value.
|
||||||
*/
|
*/
|
||||||
editable: {
|
editable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false
|
value: false
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The immediate value of the slider. This value is updated while the user
|
* The immediate value of the slider. This value is updated while the user
|
||||||
* is dragging the slider.
|
* is dragging the slider.
|
||||||
*/
|
*/
|
||||||
immediateValue: {
|
immediateValue: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0,
|
value: 0,
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of markers
|
* The maximum number of markers
|
||||||
*/
|
*/
|
||||||
maxMarkers: {
|
maxMarkers: {
|
||||||
type: Number,
|
type: Number,
|
||||||
value: 0,
|
value: 0,
|
||||||
notify: true,
|
notify: true,
|
||||||
observer: '_maxMarkersChanged'
|
observer: '_maxMarkersChanged'
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the knob is expanded
|
* If true, the knob is expanded
|
||||||
*/
|
*/
|
||||||
expand: {
|
expand: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True when the user is dragging the slider.
|
* True when the user is dragging the slider.
|
||||||
*/
|
*/
|
||||||
dragging: {
|
dragging: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
transiting: {
|
transiting: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: false,
|
value: false,
|
||||||
readOnly: true
|
readOnly: true
|
||||||
},
|
},
|
||||||
|
|
||||||
markers: {
|
markers: {
|
||||||
type: Array,
|
type: Array,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
value: []
|
value: []
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
observers: [
|
observers: [
|
||||||
'_updateKnob(value, min, max, snaps, step)',
|
'_updateKnob(value, min, max, snaps, step)',
|
||||||
'_minChanged(min)',
|
'_minChanged(min)',
|
||||||
'_maxChanged(max)',
|
'_maxChanged(max)',
|
||||||
'_valueChanged(value)',
|
'_valueChanged(value)',
|
||||||
'_immediateValueChanged(immediateValue)'
|
'_immediateValueChanged(immediateValue)'
|
||||||
],
|
],
|
||||||
|
|
||||||
hostAttributes: {
|
hostAttributes: {
|
||||||
role: 'slider',
|
role: 'slider',
|
||||||
tabindex: 0
|
tabindex: 0
|
||||||
},
|
},
|
||||||
|
|
||||||
keyBindings: {
|
keyBindings: {
|
||||||
'left down pagedown home': '_decrementKey',
|
'left down pagedown home': '_decrementKey',
|
||||||
'right up pageup end': '_incrementKey'
|
'right up pageup end': '_incrementKey'
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function () {
|
ready: function() {
|
||||||
// issue polymer/polymer#1305
|
// issue polymer/polymer#1305
|
||||||
this.async(function () {
|
|
||||||
this._updateKnob(this.value);
|
|
||||||
this._updateInputValue();
|
|
||||||
}, 1);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
this.async(function() {
|
||||||
* Increases value by `step` but not above `max`.
|
this._updateKnob(this.value);
|
||||||
* @method increment
|
}, 1);
|
||||||
*/
|
},
|
||||||
increment: function () {
|
|
||||||
this.value = this._clampValue(this.value + this.step);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decreases value by `step` but not below `min`.
|
|
||||||
* @method decrement
|
|
||||||
*/
|
|
||||||
decrement: function () {
|
|
||||||
this.value = this._clampValue(this.value - this.step);
|
|
||||||
},
|
|
||||||
|
|
||||||
_updateKnob: function (value) {
|
|
||||||
this._positionKnob(this._calcRatio(value));
|
|
||||||
},
|
|
||||||
|
|
||||||
_minChanged: function () {
|
|
||||||
this.setAttribute('aria-valuemin', this.min);
|
|
||||||
},
|
|
||||||
|
|
||||||
_maxChanged: function () {
|
|
||||||
this.setAttribute('aria-valuemax', this.max);
|
|
||||||
},
|
|
||||||
|
|
||||||
_valueChanged: function () {
|
|
||||||
this.setAttribute('aria-valuenow', this.value);
|
|
||||||
this.fire('value-change');
|
|
||||||
},
|
|
||||||
|
|
||||||
_immediateValueChanged: function () {
|
|
||||||
if (this.dragging) {
|
|
||||||
this.fire('immediate-value-change');
|
|
||||||
} else {
|
|
||||||
this.value = this.immediateValue;
|
|
||||||
}
|
|
||||||
this._updateInputValue();
|
|
||||||
},
|
|
||||||
|
|
||||||
_secondaryProgressChanged: function () {
|
|
||||||
this.secondaryProgress = this._clampValue(this.secondaryProgress);
|
|
||||||
},
|
|
||||||
|
|
||||||
_updateInputValue: function () {
|
|
||||||
if (this.editable) {
|
|
||||||
this.$$('#input').value = this.immediateValue.toString();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_expandKnob: function () {
|
|
||||||
this._setExpand(true);
|
|
||||||
},
|
|
||||||
|
|
||||||
_resetKnob: function () {
|
|
||||||
this.cancelDebouncer('expandKnob');
|
|
||||||
this._setExpand(false);
|
|
||||||
},
|
|
||||||
|
|
||||||
_positionKnob: function (ratio) {
|
|
||||||
this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio)));
|
|
||||||
this._setPinValue(this.immediateValue);
|
|
||||||
|
|
||||||
this._setRatio(this._calcRatio(this.immediateValue));
|
|
||||||
|
|
||||||
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;
|
|
||||||
},
|
|
||||||
|
|
||||||
_onTrack: function (event) {
|
|
||||||
switch (event.detail.state) {
|
|
||||||
case 'start':
|
|
||||||
this._trackStart(event);
|
|
||||||
break;
|
|
||||||
case 'track':
|
|
||||||
this._trackX(event);
|
|
||||||
break;
|
|
||||||
case 'end':
|
|
||||||
this._trackEnd();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_trackStart: function (event) {
|
|
||||||
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._setDragging(true);
|
|
||||||
},
|
|
||||||
|
|
||||||
_trackX: function (e) {
|
|
||||||
if (!this.dragging) {
|
|
||||||
this._trackStart(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
var dx = Math.min(this._maxx, Math.max(this._minx, e.detail.dx));
|
|
||||||
this._x = this._startx + dx;
|
|
||||||
|
|
||||||
var immediateValue = this._calcStep(this._calcKnobPosition(this._x / this._w));
|
|
||||||
this._setImmediateValue(immediateValue);
|
|
||||||
this._setPinValue(immediateValue);
|
|
||||||
|
|
||||||
// update knob's position
|
|
||||||
var translateX = ((this._calcRatio(immediateValue) * this._w) - this._startx);
|
|
||||||
this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob);
|
|
||||||
},
|
|
||||||
|
|
||||||
_trackEnd: function () {
|
|
||||||
var s = this.$.sliderKnob.style;
|
|
||||||
|
|
||||||
this.$.sliderKnob.classList.remove('dragging');
|
|
||||||
this._setDragging(false);
|
|
||||||
this._resetKnob();
|
|
||||||
this.value = this.immediateValue;
|
|
||||||
|
|
||||||
s.transform = s.webkitTransform = '';
|
|
||||||
|
|
||||||
this.fire('change');
|
|
||||||
},
|
|
||||||
|
|
||||||
_knobdown: function (event) {
|
|
||||||
this._expandKnob();
|
|
||||||
|
|
||||||
// cancel selection
|
|
||||||
event.detail.sourceEvent.preventDefault();
|
|
||||||
|
|
||||||
// set the focus manually because we will called prevent default
|
|
||||||
this.focus();
|
|
||||||
},
|
|
||||||
|
|
||||||
_bardown: function (event) {
|
|
||||||
this._w = this.$.sliderBar.offsetWidth;
|
|
||||||
var rect = this.$.sliderBar.getBoundingClientRect();
|
|
||||||
var ratio = (event.detail.x - rect.left) / this._w;
|
|
||||||
var prevRatio = this.ratio;
|
|
||||||
|
|
||||||
this._setTransiting(true);
|
|
||||||
|
|
||||||
this._positionKnob(ratio);
|
|
||||||
|
|
||||||
this.debounce('expandKnob', this._expandKnob, 60);
|
|
||||||
|
|
||||||
// if the ratio doesn't change, sliderKnob's animation won't start
|
|
||||||
// and `_knobTransitionEnd` won't be called
|
|
||||||
// Therefore, we need to manually update the `transiting` state
|
|
||||||
|
|
||||||
if (prevRatio === this.ratio) {
|
|
||||||
this._setTransiting(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.async(function () {
|
|
||||||
this.fire('change');
|
|
||||||
});
|
|
||||||
|
|
||||||
// cancel selection
|
|
||||||
event.detail.sourceEvent.preventDefault();
|
|
||||||
},
|
|
||||||
|
|
||||||
_knobTransitionEnd: function (event) {
|
|
||||||
if (event.target === this.$.sliderKnob) {
|
|
||||||
this._setTransiting(false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_maxMarkersChanged: function (maxMarkers) {
|
|
||||||
var l = (this.max - this.min) / this.step;
|
|
||||||
if (!this.snaps && l > maxMarkers) {
|
|
||||||
this._setMarkers([]);
|
|
||||||
} else {
|
|
||||||
this._setMarkers(new Array(l));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_getClassNames: function () {
|
|
||||||
var classes = {};
|
|
||||||
|
|
||||||
classes.disabled = this.disabled;
|
|
||||||
classes.pin = this.pin;
|
|
||||||
classes.snaps = this.snaps;
|
|
||||||
classes.ring = this.immediateValue <= this.min;
|
|
||||||
classes.expand = this.expand;
|
|
||||||
classes.dragging = this.dragging;
|
|
||||||
classes.transiting = this.transiting;
|
|
||||||
classes.editable = this.editable;
|
|
||||||
|
|
||||||
return Object.keys(classes).filter(
|
|
||||||
function (className) {
|
|
||||||
return classes[className];
|
|
||||||
}).join(' ');
|
|
||||||
},
|
|
||||||
|
|
||||||
_incrementKey: function (event) {
|
|
||||||
if (event.detail.key === 'end') {
|
|
||||||
this.value = this.max;
|
|
||||||
} else {
|
|
||||||
this.increment();
|
|
||||||
}
|
|
||||||
this.fire('change');
|
|
||||||
},
|
|
||||||
|
|
||||||
_decrementKey: function (event) {
|
|
||||||
if (event.detail.key === 'home') {
|
|
||||||
this.value = this.min;
|
|
||||||
} else {
|
|
||||||
this.decrement();
|
|
||||||
}
|
|
||||||
this.fire('change');
|
|
||||||
},
|
|
||||||
|
|
||||||
_setPinValue: function (value) {
|
|
||||||
this.pinValue = value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when the slider's value changes.
|
* Increases value by `step` but not above `max`.
|
||||||
*
|
* @method increment
|
||||||
* @event value-change
|
|
||||||
*/
|
*/
|
||||||
|
increment: function() {
|
||||||
|
this.value = this._clampValue(this.value + this.step);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when the slider's immediateValue changes.
|
* Decreases value by `step` but not below `min`.
|
||||||
*
|
* @method decrement
|
||||||
* @event immediate-value-change
|
|
||||||
*/
|
*/
|
||||||
|
decrement: function() {
|
||||||
|
this.value = this._clampValue(this.value - this.step);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
_updateKnob: function(value) {
|
||||||
* Fired when the slider's value changes due to user interaction.
|
this._positionKnob(this._calcRatio(value));
|
||||||
*
|
},
|
||||||
* Changes to the slider's value due to changes in an underlying
|
|
||||||
* bound variable will not trigger this event.
|
_minChanged: function() {
|
||||||
*
|
this.setAttribute('aria-valuemin', this.min);
|
||||||
* @event change
|
},
|
||||||
*/
|
|
||||||
|
_maxChanged: function() {
|
||||||
|
this.setAttribute('aria-valuemax', this.max);
|
||||||
|
},
|
||||||
|
|
||||||
|
_valueChanged: function() {
|
||||||
|
this.setAttribute('aria-valuenow', this.value);
|
||||||
|
this.fire('value-change');
|
||||||
|
},
|
||||||
|
|
||||||
|
_immediateValueChanged: function() {
|
||||||
|
if (this.dragging) {
|
||||||
|
this.fire('immediate-value-change');
|
||||||
|
} else {
|
||||||
|
this.value = this.immediateValue;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_secondaryProgressChanged: function() {
|
||||||
|
this.secondaryProgress = this._clampValue(this.secondaryProgress);
|
||||||
|
},
|
||||||
|
|
||||||
|
_fixForInput: function(immediateValue) {
|
||||||
|
// paper-input/issues/114
|
||||||
|
return this.immediateValue.toString();
|
||||||
|
},
|
||||||
|
|
||||||
|
_expandKnob: function() {
|
||||||
|
this._setExpand(true);
|
||||||
|
},
|
||||||
|
|
||||||
|
_resetKnob: function() {
|
||||||
|
this.cancelDebouncer('expandKnob');
|
||||||
|
this._setExpand(false);
|
||||||
|
},
|
||||||
|
|
||||||
|
_positionKnob: function(ratio) {
|
||||||
|
this._setImmediateValue(this._calcStep(this._calcKnobPosition(ratio)));
|
||||||
|
this._setPinValue(this.immediateValue);
|
||||||
|
this._setRatio(this._calcRatio(this.immediateValue));
|
||||||
|
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onTrack: function(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
switch (event.detail.state) {
|
||||||
|
case 'start':
|
||||||
|
this._trackStart(event);
|
||||||
|
break;
|
||||||
|
case 'track':
|
||||||
|
this._trackX(event);
|
||||||
|
break;
|
||||||
|
case 'end':
|
||||||
|
this._trackEnd();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_trackStart: function(event) {
|
||||||
|
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._setDragging(true);
|
||||||
|
},
|
||||||
|
|
||||||
|
_trackX: function(e) {
|
||||||
|
if (!this.dragging) {
|
||||||
|
this._trackStart(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dx = Math.min(this._maxx, Math.max(this._minx, e.detail.dx));
|
||||||
|
this._x = this._startx + dx;
|
||||||
|
|
||||||
|
var immediateValue = this._calcStep(this._calcKnobPosition(this._x / this._w));
|
||||||
|
this._setImmediateValue(immediateValue);
|
||||||
|
|
||||||
|
// update knob's position
|
||||||
|
var translateX = ((this._calcRatio(immediateValue) * this._w) - this._startx);
|
||||||
|
this.translate3d(translateX + 'px', 0, 0, this.$.sliderKnob);
|
||||||
|
this._setPinValue(immediateValue);
|
||||||
|
},
|
||||||
|
|
||||||
|
_trackEnd: function() {
|
||||||
|
var s = this.$.sliderKnob.style;
|
||||||
|
|
||||||
|
this.$.sliderKnob.classList.remove('dragging');
|
||||||
|
this._setDragging(false);
|
||||||
|
this._resetKnob();
|
||||||
|
this.value = this.immediateValue;
|
||||||
|
|
||||||
|
s.transform = s.webkitTransform = '';
|
||||||
|
|
||||||
|
this.fire('change');
|
||||||
|
},
|
||||||
|
|
||||||
|
_knobdown: function(event) {
|
||||||
|
this._expandKnob();
|
||||||
|
|
||||||
|
// cancel selection
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
// set the focus manually because we will called prevent default
|
||||||
|
this.focus();
|
||||||
|
},
|
||||||
|
|
||||||
|
_bardown: function(event) {
|
||||||
|
this._w = this.$.sliderBar.offsetWidth;
|
||||||
|
var rect = this.$.sliderBar.getBoundingClientRect();
|
||||||
|
var ratio = (event.detail.x - rect.left) / this._w;
|
||||||
|
var prevRatio = this.ratio;
|
||||||
|
|
||||||
|
this._setTransiting(true);
|
||||||
|
|
||||||
|
this._positionKnob(ratio);
|
||||||
|
|
||||||
|
this.debounce('expandKnob', this._expandKnob, 60);
|
||||||
|
|
||||||
|
// if the ratio doesn't change, sliderKnob's animation won't start
|
||||||
|
// and `_knobTransitionEnd` won't be called
|
||||||
|
// Therefore, we need to manually update the `transiting` state
|
||||||
|
|
||||||
|
if (prevRatio === this.ratio) {
|
||||||
|
this._setTransiting(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.async(function() {
|
||||||
|
this.fire('change');
|
||||||
|
});
|
||||||
|
|
||||||
|
// cancel selection
|
||||||
|
event.preventDefault();
|
||||||
|
},
|
||||||
|
|
||||||
|
_knobTransitionEnd: function(event) {
|
||||||
|
if (event.target === this.$.sliderKnob) {
|
||||||
|
this._setTransiting(false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_maxMarkersChanged: function(maxMarkers) {
|
||||||
|
var l = (this.max - this.min) / this.step;
|
||||||
|
if (!this.snaps && l > maxMarkers) {
|
||||||
|
this._setMarkers([]);
|
||||||
|
} else {
|
||||||
|
this._setMarkers(new Array(l));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_mergeClasses: function(classes) {
|
||||||
|
return Object.keys(classes).filter(
|
||||||
|
function(className) {
|
||||||
|
return classes[className];
|
||||||
|
}).join(' ');
|
||||||
|
},
|
||||||
|
|
||||||
|
_getClassNames: function() {
|
||||||
|
var classes = {};
|
||||||
|
|
||||||
|
classes.disabled = this.disabled;
|
||||||
|
classes.pin = this.pin;
|
||||||
|
classes.snaps = this.snaps;
|
||||||
|
classes.ring = this.immediateValue <= this.min;
|
||||||
|
classes.expand = this.expand;
|
||||||
|
classes.dragging = this.dragging;
|
||||||
|
classes.transiting = this.transiting;
|
||||||
|
classes.editable = this.editable;
|
||||||
|
|
||||||
|
return this._mergeClasses(classes);
|
||||||
|
},
|
||||||
|
|
||||||
|
_getProgressClass: function() {
|
||||||
|
return this._mergeClasses({
|
||||||
|
transiting: this.transiting
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_incrementKey: function(event) {
|
||||||
|
if (event.detail.key === 'end') {
|
||||||
|
this.value = this.max;
|
||||||
|
} else {
|
||||||
|
this.increment();
|
||||||
|
}
|
||||||
|
this.fire('change');
|
||||||
|
},
|
||||||
|
|
||||||
|
_decrementKey: function(event) {
|
||||||
|
if (event.detail.key === 'home') {
|
||||||
|
this.value = this.min;
|
||||||
|
} else {
|
||||||
|
this.decrement();
|
||||||
|
}
|
||||||
|
this.fire('change');
|
||||||
|
},
|
||||||
|
_setPinValue: function (value) {
|
||||||
|
this.pinValue = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fired when the slider's value changes.
|
||||||
|
*
|
||||||
|
* @event value-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
|
||||||
|
*/
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<dom-module id="paper-menu" assetpath="bower_components/paper-menu/">
|
<dom-module id="paper-menu" assetpath="bower_components/paper-menu/">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue