jquery旋钮显示输入完成

时间:2015-03-02 10:14:14

标签: javascript jquery canvas jquery-knob

我正在使用jquery旋钮以图形方式表示我的数据。

https://github.com/aterrien/jQuery-Knob

我只想在动画之后显示输入值(在圆圈的中心),但我没有找到。我的aproach是最初set'displayInput'为false,并使用complete函数在动画后将其设置为true。我可以看到它适用于fgColor属性,但不适用于displayInput属性。

elm.knob({
    'width': 60,
    'height': 60,
    'min': 0,
    'max': 6,
    'step': 0.1,
    'readOnly': true,
    'thickness': .5,
    'dynamicDraw': true,
    'displayInput': false,
    'fgColor': dangerLevelColor,
    'inputColor': '#7F8C8D',
    format: function (value) {
        return value + '/6';
    }
});
$({value: 0}).animate({value: dangerLevel}, {
    duration: 1500,
    easing: 'swing',
    progress: function () {
        elm.val(this.value).trigger('change');
    },
    complete: function () {
        elm.trigger(
                'configure', {
                    'displayInput': true,
                    'fgColor': 'green'
                });
    }
});

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:1)

我遇到了类似的问题。似乎是某种类型的错误,但我无法追踪它。它反向工作(从displayInput:true开始,稍后使用configure更改为false)。我作为解决方法所做的是将displayInput设置为true并使用inputColor选项通过使其与背景颜色相同来“隐藏”它,并在您想要显示时将其设置为其他可见颜色。

初始化为隐藏(在白色背景上)

 $(".knob").knob({ 'inputColor': '#FFFFFF' });

显示

$(".knob").trigger('configure', { 'inputColor': '#87CEEB' });
相关问题