简体   繁体   English

起始位置在MooTools滑块类的底部而不是顶部

[英]Starting position at bottom of MooTools slider class instead of top

Is there a way to hook into the MooTools Slider class, so the starting position of the knob is at the bottom (step 0) of the bar and you drag the knob up to get to the top of the bar (step 100). 有没有一种方法可以挂接到MooTools Slider类,所以旋钮的起始位置在工具条的底部(步骤0),然后向上拖动旋钮以到达工具条的顶部(步骤100)。

This is what I have so far: 这是我到目前为止的内容:

var slider1 = new Slider('#bar', '#knob', {
    offset: 6,
    steps: 100,
    mode: 'vertical'
});

And what I need: 而我需要的是:

slider1.startingPosition = 'bottom';

Or something to that affect. 或有什么影响。

Since steps is defined to 100, your max value is 100, which is what you want to set as initialStep (the slider starting point). 由于将steps定义为100,因此最大值为100,这是您要设置为initialStep (滑块起点)的值。

For your specific CSS I would remove (or add it womewhere else) the margin on the element of the slider, so it wont shift the slider. 对于您的特定CSS,我会删除(或在其他地方添加)滑块元素的边距,因此它不会移动滑块。

This worked for me: 这为我工作:

var slider = $('bar');

var slider1 = new Slider(slider, slider.getElement('.knob'), {
    offset: 6,
    steps: 100,
    initialStep: 100,
    mode: 'vertical',
    onChange: function (step) {
        console.log(step);
    }
});

And changed also margin top here to 0px: margin: 0px 0 0 -7px; 并将此处的边距顶部也更改为0px: margin: 0px 0 0 -7px;

Fiddle 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM