This project is archived and is in readonly mode.

#64 ✓resolved
Thomas Aylott

Slider.js : optionnal onChange gets fired when the set method is called, even when the value has not changed

Reported by Thomas Aylott | May 28th, 2008 @ 10:06 AM

Originally posted on Trac by challet

Original Trac Ticket

Description

In Slider.js, the onChange event is fired after calling the set() method (via checkStep()).

I needed to fire the event even if the step value remains the same, but I can't do it from the outside without the risk of calling twice the onChange event.

So I patched Slider.js this way :

set: function(step,forceChange){
	if (!((this.range > 0) ^ (step  0) ^ (step > this.max))) step = this.max;
		
	this.step = Math.round(step);
	this.checkStep($chk(forceChange) && forceChange);
	this.end();
	this.fireEvent('onTick', this.toPosition(this.step));
	return this;
},

checkStep: function(forceChange){
	if (this.previousChange != this.step || forceChange){
		this.previousChange = this.step;
		this.fireEvent('onChange', this.step);
	}
}

I guess it might be useful for other people.

Trac Attachments

Trac Comments

Comments and changes to this ticket

  • Bryan J Swift

    Bryan J Swift July 20th, 2008 @ 10:22 PM

    • Tag set to enhancement, minor, plugins, slider

    I'm not sure if I'm understanding this one correctly. The title and the description seem to disagree on the problem. The title says the onChange event was firing when the value didn't change but the description seems to say they needed to fire the event even if the value remains the same.

    Presumably the error is that it was firing even when it hadn't changed otherwise this should be a bug right?

  • Aaron Newton

    Aaron Newton February 19th, 2009 @ 12:18 AM

    • Tag changed from enhancement, minor, plugins, slider to enhancement, slider
    • Milestone cleared.
  • Christoph Pojer

    Christoph Pojer March 13th, 2009 @ 12:35 PM

    • Assigned user changed from “Valerio” to “Christoph Pojer”
  • Christoph Pojer

    Christoph Pojer March 13th, 2009 @ 11:03 PM

    • State changed from “new” to “resolved”

    Fixed for MooTools-More 1.0

Create your profile

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

Shared Ticket Bins

Pages