you need more calculations.
the first time you "click" above the slider, you need to memorize the x-y position.
when mousemove and button is down, you then move the slider together with the mouse...