Counter data-step dynamic

General issues related to the use of Metro 4
Post Reply
gabs
Posts: 4
Joined: Fri Jun 28, 2019 9:42 am
Status: Offline

Counter data-step dynamic

Post by gabs » Fri Jun 28, 2019 10:17 am

Hello,

The Counter plugin currently doesn't allow the STEP to be changed at runtime.

a proposed solution below:


setValueAttribute: function(){
this.options.value = this.element.attr("data-value");
this._calcArray();
},

setStepAttribute: function(){
this.options.step = +this.element.attr("data-step");
this.numbers = [];
this._calcArray();
},


changeAttribute: function(attributeName){
switch (attributeName) {
case "data-value": this.setValueAttribute(); break;
case "data-step": this.setStepAttribute(); break;
}
},


example:
$(element).attr("data-step", 100);

Post Reply