Permalink
Browse files

Pad against document borders

  • Loading branch information...
cgst committed Jul 13, 2010
1 parent 7dcfb54 commit c87d4fcd97bcf4118a415aa485f2a12f90a06eb3
Showing with 8 additions and 5 deletions.
  1. +8 −5 popover.js
View
@@ -58,15 +58,18 @@ $.fn.popover = function(options) {
floater.height(floater.height() + diffHeight);
}
+ // Padding against document borders
+ var padding = 18;
+
// Calculate leftOff
- leftOff = offset.left + ( buttonWidth - contentWidth)/2;
- var diffWidth = 0
- if (leftOff < 0) {
+ leftOff = offset.left + (buttonWidth - contentWidth)/2;
+ var diffWidth = 0;
+ if (leftOff < padding) {
// out of the document at left
- diffWidth = -leftOff;
+ diffWidth = leftOff - padding;
} else if (leftOff + contentWidth > docWidth) {
// left of the screen right
- diffWidth = leftOff + contentWidth - docWidth;
+ diffWidth = leftOff + contentWidth - docWidth + padding;
}
// position triangle

0 comments on commit c87d4fc

Please sign in to comment.