When you write:
window.onmousemove = dragMove;
window.onmouseup = dragStop;
you actually SET the window.onmousemove / onmouseup functions. That is, if some functions were previously set, the next call replaces the previous one. You must have some sort of draggers container that holds references of your dragger, so that the events on window can address all of them. Or alternatively you can also replace this (although it may not be the best for performances):
window.onmousemove = dragMove;
window.onmouseup = dragStop;
with this:
var oldWinMouseMove = window.onmousemove;
var oldWinMouseUp = window.onmouseup;
window.onmousemove = function(e) {
if (typeof oldWinMouseMove === 'function') {
oldWinMouseMove(e);
}
dragMove(e);
};
window.onmouseup = function(e) {
if (typeof oldWinMouseUp === 'function') {
oldWinMouseUp(e);
}
dragStop(e);
};
Better solution
As requested, here is a better option which avoid to create a big calling stack like the solution above :
http://jsfiddle.net/bhymxrqr/10/
The idea is to register the "mousedown" event on the sliders only, and the "mousemove" and "mouseup" events on window only.
// In "Slider":
dragger.onmousedown = dragStart;
// (nothing here about mousemove/up)
On mouse down, the current slider info is stored (to be exact, the mouseup and mousemove callback are stored):
window.activeSlider = {
dragMove: dragMove,
dragStop: dragStop
};
On window mouse move, the stored "mouse move" callback is called ; and same for mouse up, with in addition removal of the stored callbacks.
///////////////////////////
// Register window global slide handlers
window.onmousemove = function(e) {
if (window.activeSlider !== undefined) {
window.activeSlider.dragMove(e);
}
}
window.onmouseup = function(e) {
if (window.activeSlider !== undefined) {
window.activeSlider.dragStop(e);
}
}