views:

310

answers:

1

Hi,

I am using mootools to create a CSS skin for the Youtube chromeless player using the javascript API to control playback. I cannot post the code unfortunately. The question I have is a more general one. When using the slider plugin a call to mySlider.set(step) moves the knob to the correct step on the slider but it triggers all of the plugins event functions (onChange, onTick, onComplete). The problem with this is, how do you know if the sliders knob position was changed by a user or a call to the set() function? I would have thought there would be a function reserved for when the knob was released by a mouse only and not be called if the position was simply set in code. I have code that updates the knobs position based on where the videos playback duration is currently at. I need to be able to move the knob to the current position in code without it thinking a user let go of the knob.

To simplify the question, is there a way to set the knobs position on a slider in code without triggering the functions used when a user interacts?

You can find the Slider plugin reference here http://mootools.net/docs/more/Drag/Slider

Thanks

A: 

Make a variable that indicates that you're setting it programatically, then skip your event handlers if the variable is true.

Then, each time you set the slider in code, set the variable to true first, then back to false afterwords in a finally block.

SLaks