javascript - Enyo JS Vertical Sliders -
i trying code vertical slider in enyo (like control on mixing desk). trying avoid starting scratch started tweaking onyx.slider class. changed styles left top , width height , few other tweaks, it's working. i'm stuck on getting slider fill bottom top @ minute vertical fills top down. in advance help.
here code changes have done:
in progressbar.js:
updatebarposition: function(inpercent) { this.$.bar.applystyle("height", inpercent + "%"); }, in slider.js (dividing 64 temporary hack):
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
there couple of approaches take. obvious (except fact didn't occur me first) swap background/gradient of bar , bar-bar. give appearance of filling bottom. recommend this.
the other method did in jsfiddle here: http://jsfiddle.net/roysutton/b9pma/ (do ignore doubled updatebarposition function)
instead of modifying files directly, derived slider , overrode appropriate functions , added new class vertical slider.
i changed 'fill' absolutely positioned within slider.
now, next problem value '0' filled , '100' empty. handled modifying calcknobposition adjust max , inverting positioning logic seen in fiddle here: http://jsfiddle.net/roysutton/b9pma/2/
return this.max - (y / this.getbounds().height) * (this.max - this.min);
Comments
Post a Comment