Permalink
Browse files

Merge commit '5a8253fb430adc26b1edb0442ba674c5fd17e328'

  • Loading branch information...
jaz303 committed Apr 23, 2011
2 parents 06fd815 + 5a8253f commit 3c42f42e477ca358baf546f2393abfa31777bef5
Showing with 25 additions and 0 deletions.
  1. +25 −0 src/javascripts/jquery.tipsy.js
@@ -206,5 +206,30 @@
$.fn.tipsy.autoWE = function() {
return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
};
+
+ $.fn.tipsy.autoBounds = function(margin, prefer) {
+ return function()
+ {
+ var dir = { ns: prefer[0], ew: (prefer.length > 1 ? prefer[1] : false) }
+
+ bound_top = $(document).scrollTop() + margin;
+ bound_left = $(document).scrollLeft() + margin;
+
+ if ( $(this).offset().top < bound_top) {
+ dir.ns = 'n';
+ }
+ if ( $(this).offset().left < bound_left ) {
+ dir.ew = 'w';
+ }
+ if ( $(window).width() + $(document).scrollLeft() - $(this).offset().left < margin ) {
+ dir.ew = 'e';
+ }
+ if ( $(window).height() + $(document).scrollTop() - $(this).offset().top < margin ) {
+ dir.ns = 's';
+ }
+
+ return dir.ns + (dir.ew ? dir.ew : '');
+ }
+ };
})(jQuery);

0 comments on commit 3c42f42

Please sign in to comment.