From a5fc9eb7db292629271e6414db9e98c3dc60224d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=CC=88rn=20Zaefferer?= Date: Fri, 13 Apr 2012 16:05:29 +0200 Subject: [PATCH] Position: Expose target and element dimensions to allow further customization, like calculating the angle between the two elements --- tests/visual/position/position_feedback.html | 12 +- .../position/position_feedback_rotate.html | 105 ++++++++++++++++++ ui/jquery.ui.position.js | 17 ++- 3 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 tests/visual/position/position_feedback_rotate.html diff --git a/tests/visual/position/position_feedback.html b/tests/visual/position/position_feedback.html index 5b50ff32c..f23d8a299 100644 --- a/tests/visual/position/position_feedback.html +++ b/tests/visual/position/position_feedback.html @@ -13,13 +13,13 @@ + + + + + + + + + +
all around me
+ +
+ + + diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 31da2237b..17d43b2a4 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -241,9 +241,22 @@ $.fn.position = function( options ) { top = targetOffset.top - props.top, bottom = (targetOffset.top + targetHeight) - (props.top + elemHeight), feedback = { + target: { + element: target, + left: targetOffset.left, + top: targetOffset.top, + width: targetWidth, + height: targetHeight + }, + element: { + element: elem, + left: props.left, + top: props.top, + width: elemWidth, + height: elemHeight + }, horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", - vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle", - target: target + vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" }, max = Math.max, abs = Math.abs; -- 2.39.5