This project is archived and is in readonly mode.

#45 ✓resolved
Thomas Aylott

Slider: onComplete() is fired before onTick()

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

Originally posted on Trac by lebowski

Original Trac Ticket

Description

When clicking the knob, the 'onComplete' event is fired before 'onTick'.

I thing, 'onComplete' should be fired when you are done dragging.

You can find this in the beta docs:

onComplete - Fire when you're done dragging.

When you use the slider, you the following events are fired:

        (mousedown)
        onComplete
        onTick
        (mouseup)
        onComplete

JS:

var slider = new Slider('myElement','myKnob', {
  steps: 100,
  wheel: false,
  onTick: function(pos){
    console.log('onTick');
  },
  onComplete: function(step){
    console.log('onComplete');
  }
});

HTML:

Used software: MooTools r1502, Firefox 2.x / Safari 3.x

An example of this problem can be found under:

http://dev.mixable.de/slider-tes...

Trac Attachments

Trac Comments

Changed 1 month ago by seventhapex


        
I believe this is because Slider is registering a "mouseup" event on the track even when clicking on the knob. I believe a simple fix would be to change the Slider.track.addEvent('mouseup') event to a "click" event; 

FROM: 

this.element.addEvent('mouseup', this.clickedElement.bind(this));

TO: 

this.element.addEvent('click', this.clickedElement.bind(this));

      

Changed 1 month ago by seventhapex


        
sorry.. that's the "mousedown" event that should be replaced. 

      

Changed 1 month ago by seventhapex


        
That diddn't work either... But this does the trick; 

this.element.addEvent('mousedown', this.clickedElement.bind(this));

		// keep track from firing the 'mousedown' event if the knob has been hovored
		this.knob.addEvent('mouseenter',function(){
  		this.element.removeEvents('mousedown');
		}.bind(this));
		this.knob.addEvent('mouseleave',function(){
  		this.element.addEvent('mousedown', this.clickedElement.bind(this));
		}.bind(this));

      

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

Tags

Pages