Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Position preview when space to right is limited

  • Loading branch information...
commit fa3f198a56cfb513ea1ae72016ebd292372da0cd 1 parent ae86245
@huyz authored
View
5 gpme.css
@@ -441,6 +441,11 @@ div.gpme-enh .gpme-comment-count-fg {
width: 17px;
background: url('chrome-extension://__MSG_@@extension_id__/images/preview-triangle.png') no-repeat;
}
+.gpme-folded:not(.Up) .gpme-preview-right > .gpme-preview-triangle {
+ right: -16px;
+ left: auto;
+ background: url('chrome-extension://__MSG_@@extension_id__/images/preview-triangle-right.png') no-repeat;
+}
.gpme-folded:not(.Up) .Fh { /* Context menu button */
position: absolute;
View
42 gpme.js
@@ -241,6 +241,8 @@ var _C_TWEAK_EZMNTN = '.bcGTweakEzMntn';
// CSS values shared with our CSS file
var TRIANGLE_HEIGHT = 30;
+var TRIANGLE_WIDTH = 17;
+var RIGHT_BUTTON_AREA_OFFSET_LEFT = 20 + 4;
var POST_WRAPPER_PADDING_TOP = 6;
var POST_WRAPPER_PADDING_BOTTOM = 6;
var ITEM_LINE_HEIGHT = 22;
@@ -3289,8 +3291,7 @@ function showPreview(e) {
}
}
- var fixedHeight = fixedBarsHeight();
- var overlappingHeight = overlappingBarsHeight();
+ // Position horizontally
// Move to the right edge and as far up as possible
/* Disabled: we now move based on right-edge instead of left-edge
@@ -3302,11 +3303,38 @@ function showPreview(e) {
// We give slack of 10 coz otherwise you get the horizontal bar flashing on Chrome OSX.
// The width of the popup is reduced by 8 in CSS to leave a bit of a gap between posts and the popup so
// that the popup triangle can nicely overlay a big commentcount.
- $post.css('right', '' +
- -Math.min($post.outerWidth() + 8,
- ($(document).width() - $(window).scrollLeft() - $item.get(0).getBoundingClientRect().right - 10)) +
- 'px');
- $post.css('left', 'auto');
+ //var spaceToRight = $(document).width() - $(window).scrollLeft() - $item.get(0).getBoundingClientRect().right - 10;
+ var spaceToRight = $(document).width() - $item.offset().left - $item.width() - 10;
+ var widthNeeded = $post.outerWidth() + 8;
+
+ // Place to the right if there's room
+ if (spaceToRight >= widthNeeded) {
+ $post.css('right', '' + -Math.min(widthNeeded, spaceToRight) + 'px');
+ $post.css('left', 'auto');
+ $post.removeClass('gpme-preview-right');
+ } else {
+ var spaceToLeft = $item.offset().left;
+ debug(e);
+ debug("e.offsetX=" + e.offsetX + " boundary=" + ($item.width() - RIGHT_BUTTON_AREA_OFFSET_LEFT - 2));
+ // Place over the posts to the left of the right button area if there's no room on the left
+ // or if the mouse is over to the right, near the button area.
+ if (spaceToLeft < widthNeeded ||
+ e.pageX >= spaceToLeft + $item.width() - RIGHT_BUTTON_AREA_OFFSET_LEFT) {
+ $post.css('right', '' + (RIGHT_BUTTON_AREA_OFFSET_LEFT + TRIANGLE_WIDTH - 3) + 'px');
+ $post.css('left', 'auto');
+ } else {
+ // Place to the left
+ $post.css('left', '' + -Math.min(widthNeeded, spaceToLeft) + 'px');
+ $post.css('right', 'auto');
+ }
+ $post.addClass('gpme-preview-right');
+ }
+
+ // Position vertically
+
+ var fixedHeight = fixedBarsHeight();
+ var overlappingHeight = overlappingBarsHeight();
+
var offsetY = Math.max(POST_WRAPPER_PADDING_TOP,
Math.min($post.outerHeight() - TRIANGLE_HEIGHT - POST_WRAPPER_PADDING_BOTTOM,
$item.offset().top -
View
BIN  images/preview-triangle-right.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
8 jquery.hoverIntent.js
@@ -52,9 +52,11 @@
// cX, cY = current X and Y position of mouse, updated by mousemove event
// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
var cX, cY, pX, pY;
+ var currentEvent;
// A private function for getting mouse position
var track = function(ev) {
+ currentEvent = ev;
cX = ev.pageX;
cY = ev.pageY;
};
@@ -65,7 +67,11 @@
// compare mouse positions to see if they've crossed the threshold
if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
$(ob).unbind("mousemove",track);
- ob.hoverIntent_t = setTimeout( function(){delayOver(ev, ob);} , cfg.delayIn );
+
+ // huyz 2011-08-20
+ // We want the current mouse position, not the entry point.
+ // Not sure what other things in the event are different, but we don't care for G+me
+ ob.hoverIntent_t = setTimeout( function(){delayOver(/*ev*/ currentEvent, ob);} , cfg.delayIn );
// huyz 2011-08-13
// Call any immediateHandlerIn if applicable
View
2  manifest.json
@@ -1,7 +1,7 @@
{
"default_locale": "en",
"name": "__MSG_extensionName__",
- "version": "5.32",
+ "version": "5.33",
"minimum_chrome_version": "12",
"description": "__MSG_extensionDescription__",
Please sign in to comment.
Something went wrong with that request. Please try again.