Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get immediate value /current value of paper-slider on change event or immediate value change event

i am trying to change the background color of div on change function of paper slider with slider's current value but failed to get value of slider i have tried on-immediate-value-change or on-change function ,but i don't know how to get current value of paper-slider

like image 663
Tushar Purohit Avatar asked Jan 08 '23 20:01

Tushar Purohit


1 Answers

Well, according to the documentation, there are two different kinds of value for the paper-slider:

  • value The number that represents the current value.
  • immediateValue The immediate value of the slider. This value is updated while the user is dragging the slider.

One can access these properties directly on the paper-slider element.

While the user drags the slider, a first event is fired continuously: immediate-value-change. When the user stops dragging the slider, two other events are fired: change and value-change. The difference between the two is that the change event is only fired on user's interaction.

Considering these informations, you may add to your host element the following snippets (your slider should have a slider id, but you can obviously change that):

listeners: {
    'immediate-value-change': 'immediateValueChangeHandler',
    'change': 'changeHandler'
},

immediateValueChangeHandler: function (e) {
    var value = this.$.slider.immediateValue;
    // do something
},

changeHandler: function (e) {
    var value = this.$.slider.value;
    // do something
}
like image 68
grebett Avatar answered Jan 23 '23 02:01

grebett