Permalink
Browse files

Update mousedrag example for mobile / touch.

Fixes #177.
  • Loading branch information...
1 parent 80ff647 commit d9f51d5384976a64abb6dd68af14672184539f03 @cesutherland cesutherland committed Jan 26, 2013
Showing with 6 additions and 10 deletions.
  1. +6 −10 examples/js/examples/mouse-drag.js
@@ -46,31 +46,27 @@ function mouse_drag (container) {
function initializeDrag (e) {
start = graph.getEventPosition(e);
- Flotr.EventAdapter.observe(document, 'mousemove', move);
- Flotr.EventAdapter.observe(document, 'mouseup', stopDrag);
+ Flotr.EventAdapter.observe(container, 'flotr:mousemove', move);
+ Flotr.EventAdapter.observe(container, 'flotr:mouseup', stopDrag);
}
- function move (e) {
+ function move (e, o) {
var
- end = graph.getEventPosition(e),
xaxis = graph.axes.x,
- offset = start.x - end.x;
-
+ offset = start.x - o.x;
graph = drawGraph({
xaxis : {
min : xaxis.min + offset,
max : xaxis.max + offset
}
});
- // @todo: refector initEvents in order not to remove other observed events
- Flotr.EventAdapter.observe(graph.overlay, 'mousedown', initializeDrag);
}
function stopDrag () {
- Flotr.EventAdapter.stopObserving(document, 'mousemove', move);
+ Flotr.EventAdapter.stopObserving(container, 'flotr:mousemove', move);
}
- Flotr.EventAdapter.observe(graph.overlay, 'mousedown', initializeDrag);
+ Flotr.EventAdapter.observe(container, 'flotr:mousedown', initializeDrag);
};

0 comments on commit d9f51d5

Please sign in to comment.