r3290 committed - tooltip-callout: take dimensions into account

r3290 committed - tooltip-callout: take dimensions into account


Revision: 3290
Author: joern.zaefferer
Date: Thu Sep 24 06:08:23 2009
Log: tooltip-callout: take dimensions into account
http://code.google.com/p/jquery-ui/source/detail?r=3290
Modified:
/branches/labs/tooltip-callout/index.html
=======================================
--- /branches/labs/tooltip-callout/index.html    Wed Sep 23 13:51:39 2009
+++ /branches/labs/tooltip-callout/index.html    Thu Sep 24 06:08:23 2009
@@ -28,13 +28,14 @@
var targetY = y2 + 0.5 * h2;
var angle = Math.atan2(targetY - currentY, targetX -
currentX);
-
+ var alpha = Math.atan(h1/w1);
+
var cutX = 0,
        cutY = 0,
                    orientation;
// on the right
- if ((-0.25) * Math.PI <= angle && angle < Math.PI / 4) {
+ if((-1)*alpha <= angle && angle <= alpha){
cutX = currentX + 0.5 * w1;
cutY = currentY + Math.tan(angle) * (0.5 * w1);
                    orientation = "rc";
@@ -42,7 +43,7 @@
                    offsetY = 0;
} else
// below
- if (Math.PI / 4 <= angle && angle < Math.PI * 0.75) {
+ if(alpha < angle && angle < (Math.PI - alpha)){
cutY = currentY + 0.5 * h1;
cutX = currentX - Math.tan(angle - (Math.PI / 2)) *
(0.5 * h1);
                    orientation = "bc";
@@ -50,7 +51,7 @@
                    offsetY += offsetY / 2;
} else
// on the left
- if (Math.PI * 0.75 <= angle || angle < (-0.75) * Math.PI) {
+ if((Math.PI - alpha) <= angle || angle <= (alpha -
Math.PI)){
cutX = currentX - 0.5 * w1;
cutY = currentY - Math.tan(angle - (Math.PI)) * (0.5 *
w1);
                    orientation = "lc";
@@ -58,7 +59,7 @@
                    offsetY = 0;
} else
// above
- if (Math.PI * (-0.75) <= angle && angle < (-0.25) *
Math.PI) {
+ if ((alpha - Math.PI) < angle && angle < (-1)*alpha){
cutY = currentY - 0.5 * h1;
cutX = currentX + Math.tan(angle - (Math.PI * 1.5)) *
(0.5 * h1);
                    orientation = "tc";
@@ -130,4 +131,4 @@
</div>
</body>
-</html>
+</html>