我想在enyo中编写一个垂直滑块(就像在混音台上的一个控件一样)。我试图避免从头开始,所以我开始调整onyx.Slider类。我改变了从左到顶,从宽度到高度的风格,以及其他一些调整,它的工作。我现在坚持让滑块从下往上填充,尽管它是垂直的,但从上到下填充。预先感谢您的帮助。Enyo JS Vertical Sliders
这里是代码改变我已经做:
在ProgressBar.js:
updateBarPosition: function(inPercent) {
this.$.bar.applyStyle("height", inPercent + "%");
},
在Slider.js
(除以64是一个临时劈):
valueChanged: function() {
this.value = this.clampValue(this.min, this.max, this.value);
var p = this.calcPercent(this.value);
this.updateKnobPosition(p/64);
if (this.lockBar) {
this.setProgress(this.value);
}
},
updateKnobPosition: function(inPercent) {
this.$.knob.applyStyle("top", inPercent + "%");
},
calcKnobPosition: function(inEvent) {
var y = inEvent.clientY - this.hasNode().getBoundingClientRect().top;
return (y/this.getBounds().height) * (this.max - this.min) + this.min;
},
CSS:
/* ProgressBar.css */
.onyx-progress-bar {
margin: 8px;
height: 400px;
width: 8px;
border: 1px solid rgba(15, 15, 15, 0.2);
border-radius: 3px;
background: #b8b8b8 url(./../images/gradient-invert.png) repeat-x;
background-size: auto 100%;
}
.onyx-progress-bar-bar {
height: 100%;
border-radius: 3px;
background: #58abef url(./../images/gradient.png) repeat-x;
background-size: auto 100%;
}
Tom
谢谢!也喜欢你的书。真的帮助我开始编写我正在编写的应用程序。 – tjordan
哦!谢谢你的赞美。 – Pre101