add dragpause event

This commit is contained in:
rlx 2011-04-20 16:04:21 +00:00
parent cc121a11d9
commit 07be4293a5

View file

@ -907,7 +907,7 @@ requires
function mousedown(e) { function mousedown(e) {
/* /*
better mouse events better mouse events
on mousedown: mousedown:
trigger mousedown trigger mousedown
within 250 msec: within 250 msec:
mouseup: trigger anyclick ("click" would collide with click events of certain widgets) mouseup: trigger anyclick ("click" would collide with click events of certain widgets)
@ -918,9 +918,12 @@ requires
trigger mouserepeat every 50 msec trigger mouserepeat every 50 msec
trigger dragstart trigger dragstart
mousemove: trigger drag mousemove: trigger drag
no mousemove within 250 msec:
trigger dragpause
mouseup: trigger dragend mouseup: trigger dragend
*/ */
var mouseInterval = 0; var dragTimeout = 0,
mouseInterval = 0;
if (!self.mouseTimeout) { if (!self.mouseTimeout) {
// first mousedown // first mousedown
that.triggerEvent('mousedown', e); that.triggerEvent('mousedown', e);
@ -943,6 +946,7 @@ requires
.mousemove(mousemove) .mousemove(mousemove)
.one('mouseup', function(e) { .one('mouseup', function(e) {
clearInterval(mouseInterval); clearInterval(mouseInterval);
clearTimeout(dragTimeout);
Ox.UI.$window.unbind('mousemove', mousemove); Ox.UI.$window.unbind('mousemove', mousemove);
that.triggerEvent('dragend', e); that.triggerEvent('dragend', e);
}); });
@ -959,6 +963,12 @@ requires
} }
Ox.UI.$window.one('mouseup', mouseup); Ox.UI.$window.one('mouseup', mouseup);
function mousemove(e) { function mousemove(e) {
clearTimeout(dragTimeout);
dragTimeout = setTimeout(function() {
that.triggerEvent({
dragpause: e
});
}, 250);
that.triggerEvent('drag', e); that.triggerEvent('drag', e);
} }
function mouseup(e) { function mouseup(e) {
@ -10969,6 +10979,7 @@ requires
.bindEvent({ .bindEvent({
dragstart: dragstart, dragstart: dragstart,
drag: drag, drag: drag,
dragpause: dragpause,
dragend: dragend dragend: dragend
}) })
.appendTo(that); .appendTo(that);
@ -11016,6 +11027,7 @@ requires
.bindEvent({ .bindEvent({
dragstart: dragstartScrollbar, dragstart: dragstartScrollbar,
drag: dragScrollbar, drag: dragScrollbar,
dragpause: dragpauseScrollbar,
dragend: dragendScrollbar dragend: dragendScrollbar
}) })
.appendTo(that); .appendTo(that);
@ -11074,11 +11086,20 @@ requires
} }
} }
function dragpause(event, e) {
if (self.drag) {
Ox.print('dragpause')
dragafter();
self.drag = {x: e.clientX};
}
}
function dragend(event, e) { function dragend(event, e) {
if (self.drag) { if (self.drag) {
self.options.date = new Date( self.options.date = new Date(
+self.options.date + (self.drag.x - e.clientX) * getSecondsPerPixel() * 1000 +self.options.date + (self.drag.x - e.clientX) * getSecondsPerPixel() * 1000
); );
self.drag = null;
dragafter(); dragafter();
} }
} }
@ -11096,15 +11117,20 @@ requires
}); });
} }
function dragpauseScrollbar(event, e) {
self.drag = {x: e.clientX};
dragafter();
}
function dragendScrollbar(event, e) { function dragendScrollbar(event, e) {
self.options.date = new Date( self.options.date = new Date(
+self.options.date + (self.drag.x - e.clientX) * getSecondsPerPixel() * 1000 * 16 +self.options.date + (self.drag.x - e.clientX) * getSecondsPerPixel() * 1000 * 16
); );
self.drag = null;
dragafter(); dragafter();
} }
function dragafter() { function dragafter() {
self.drag = null;
self.$content.css({ self.$content.css({
marginLeft: 0 marginLeft: 0
}); });
@ -11192,18 +11218,15 @@ requires
var fits = true; var fits = true;
Ox.forEach(dates, function(date_) { Ox.forEach(dates, function(date_) {
if (overlaps(date, date_)) { if (overlaps(date, date_)) {
Ox.print('over', date.name, date_.name)
fits = false; fits = false;
return false; return false;
} }
}); });
if (fits) { if (fits) {
Ox.print(date.name, 'fits', line_)
line = line_; line = line_;
return false; return false;
} }
}); });
Ox.print(date.name, line)
if (line == self.$lines.length) { if (line == self.$lines.length) {
self.lineDates[line] = []; self.lineDates[line] = [];
self.$lines[line] = new Ox.Element() self.$lines[line] = new Ox.Element()