This project is archived and is in readonly mode.

#1208 ✓invalid
stephen l

Slider onChange and onComplete event fiering at init time

Reported by stephen l | March 30th, 2011 @ 12:04 AM

Sliders events should not be triggered at init time, but only when user does realy use them. setRange, set level should not trigger events. (1.2.44+)
(think using sliders as control for light power at home)

Slider.implement({                                   // prevent fire onChange and onTick events at init time, on set and on setRange
    setWithoutEvent:function(step){                 // set without event
        if (!((this.range > 0) ^ (step < this.min))) step = this.min;
        if (!((this.range > 0) ^ (step > this.max))) step = this.max;
        this.step = Math.round(step);
        return this;
    setWithEvent: function(step){                   // original set with event
            .fireEvent('tick', this.toPosition(this.step));
        return this;
    set: function(step){                            // replace original set
            .previousChange = this.step;
        return this;
    scrolledElement: function(event){               // replace original scrolledElement
        var mode = (this.options.mode == 'horizontal') ? (event.wheel < 0) : (event.wheel > 0);
        this.setWithEvent(this.step + (mode ? -1 : 1) * this.stepSize);

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket