I want my offsets back.

This commit is contained in:
Zixaphir 2015-01-11 22:34:35 -07:00
parent 03a90eb0d1
commit 3852f93f89
3 changed files with 21 additions and 14 deletions

View File

@ -7085,8 +7085,8 @@
return $.set("" + this.id + ".position", this.style.cssText);
};
hoverstart = function(_arg) {
var asapTest, cb, el, endEvents, height, latestEvent, noRemove, o, root, _ref;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, height = _arg.height, cb = _arg.cb, noRemove = _arg.noRemove;
var asapTest, cb, el, endEvents, height, latestEvent, noRemove, o, offsetX, offsetY, root, _ref;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, height = _arg.height, cb = _arg.cb, noRemove = _arg.noRemove, offsetX = _arg.offsetX, offsetY = _arg.offsetY;
o = {
root: root,
el: el,
@ -7097,7 +7097,9 @@
latestEvent: latestEvent,
clientHeight: doc.clientHeight,
clientWidth: doc.clientWidth,
noRemove: noRemove
noRemove: noRemove,
offsetX: offsetX || 45,
offsetY: offsetY || -120
};
o.hover = hover.bind(o);
o.hoverend = hoverend.bind(o);
@ -7125,12 +7127,12 @@
this.latestEvent = e;
height = this.height || this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY;
top = this.isImage ? Math.max(0, clientY * (this.clientHeight - height) / this.clientHeight) : Math.max(0, Math.min(this.clientHeight - height, clientY - 120));
top = this.isImage ? Math.max(0, clientY * (this.clientHeight - height) / this.clientHeight) : Math.max(0, Math.min(this.clientHeight - height, clientY + this.offsetY));
threshold = this.clientWidth / 2;
if (!this.isImage) {
threshold = Math.max(threshold, this.clientWidth - 400);
}
_ref = clientX <= threshold ? [clientX + 45 + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1];
_ref = clientX <= threshold ? [clientX + this.offsetX + 'px', null] : [null, this.clientWidth - clientX + this.offsetX + 'px'], left = _ref[0], right = _ref[1];
style = this.style;
style.top = top + 'px';
style.left = left;

View File

@ -7114,8 +7114,8 @@
return $.set("" + this.id + ".position", this.style.cssText);
};
hoverstart = function(_arg) {
var asapTest, cb, el, endEvents, height, latestEvent, noRemove, o, root, _ref;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, height = _arg.height, cb = _arg.cb, noRemove = _arg.noRemove;
var asapTest, cb, el, endEvents, height, latestEvent, noRemove, o, offsetX, offsetY, root, _ref;
root = _arg.root, el = _arg.el, latestEvent = _arg.latestEvent, endEvents = _arg.endEvents, asapTest = _arg.asapTest, height = _arg.height, cb = _arg.cb, noRemove = _arg.noRemove, offsetX = _arg.offsetX, offsetY = _arg.offsetY;
o = {
root: root,
el: el,
@ -7126,7 +7126,9 @@
latestEvent: latestEvent,
clientHeight: doc.clientHeight,
clientWidth: doc.clientWidth,
noRemove: noRemove
noRemove: noRemove,
offsetX: offsetX || 45,
offsetY: offsetY || -120
};
o.hover = hover.bind(o);
o.hoverend = hoverend.bind(o);
@ -7148,12 +7150,12 @@
this.latestEvent = e;
height = this.height || this.el.offsetHeight;
clientX = e.clientX, clientY = e.clientY;
top = this.isImage ? Math.max(0, clientY * (this.clientHeight - height) / this.clientHeight) : Math.max(0, Math.min(this.clientHeight - height, clientY - 120));
top = this.isImage ? Math.max(0, clientY * (this.clientHeight - height) / this.clientHeight) : Math.max(0, Math.min(this.clientHeight - height, clientY + this.offsetY));
threshold = this.clientWidth / 2;
if (!this.isImage) {
threshold = Math.max(threshold, this.clientWidth - 400);
}
_ref = clientX <= threshold ? [clientX + 45 + 'px', null] : [null, this.clientWidth - clientX + 45 + 'px'], left = _ref[0], right = _ref[1];
_ref = clientX <= threshold ? [clientX + this.offsetX + 'px', null] : [null, this.clientWidth - clientX + this.offsetX + 'px'], left = _ref[0], right = _ref[1];
style = this.style;
style.top = top + 'px';
style.left = left;

View File

@ -307,7 +307,7 @@ UI = do ->
$.off d, 'mouseup', @up
$.set "#{@id}.position", @style.cssText
hoverstart = ({root, el, latestEvent, endEvents, asapTest, height, cb, noRemove}) ->
hoverstart = ({root, el, latestEvent, endEvents, asapTest, height, cb, noRemove, offsetX, offsetY}) ->
o = {
root
el
@ -319,6 +319,8 @@ UI = do ->
clientHeight: doc.clientHeight
clientWidth: doc.clientWidth
noRemove
offsetX: offsetX or 45
offsetY: offsetY or -120
}
o.hover = hover.bind o
o.hoverend = hoverend.bind o
@ -332,6 +334,7 @@ UI = do ->
if $.x 'ancestor::div[contains(@class,"inline")][1]', root
$.on d, 'keydown', o.hoverend
$.on root, 'mousemove', o.hover
<% if (type === 'userscript') { %>
# Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955
o.workaround = (e) -> o.hoverend(e) unless root.contains e.target
@ -345,14 +348,14 @@ UI = do ->
top = if @isImage
Math.max 0, clientY * (@clientHeight - height) / @clientHeight
else
Math.max 0, Math.min(@clientHeight - height, clientY - 120)
Math.max 0, Math.min(@clientHeight - height, clientY + @offsetY)
threshold = @clientWidth / 2
threshold = Math.max threshold, @clientWidth - 400 unless @isImage
[left, right] = if clientX <= threshold
[clientX + 45 + 'px', null]
[clientX + @offsetX + 'px', null]
else
[null, @clientWidth - clientX + 45 + 'px']
[null, @clientWidth - clientX + @offsetX + 'px']
{style} = @
style.top = top + 'px'