diff options
author | Scott González <scott.gonzalez@gmail.com> | 2008-07-16 00:08:43 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2008-07-16 00:08:43 +0000 |
commit | 6cfb6208ee121f21565a12f7bf2ca57bb074b44d (patch) | |
tree | 66f1f9fb3af938e783dd5d6ff018d21b7b71bcc5 /ui | |
parent | c2ce22addf96d67d46e4da6401fb902c88613128 (diff) | |
download | jquery-ui-6cfb6208ee121f21565a12f7bf2ca57bb074b44d.tar.gz jquery-ui-6cfb6208ee121f21565a12f7bf2ca57bb074b44d.zip |
Magnifier: Partial cleanup.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.magnifier.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ui/ui.magnifier.js b/ui/ui.magnifier.js index 393a6b6f7..0dc8efbf1 100644 --- a/ui/ui.magnifier.js +++ b/ui/ui.magnifier.js @@ -99,15 +99,19 @@ $.widget("ui.magnifier", { var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
this.current = this.items[0];
- //Compute the parents distance, because we don't need to fire anything if we are not near the parent
- var overlap = ((p[0] > this.pp.left-o.distance && p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) && (p[1] > this.pp.top-o.distance && p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
+ // Compute the parent's distance
+ // we don't need to fire anything if we are not near the parent
+ var overlap = ((p[0] > this.pp.left-o.distance) &&
+ (p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) &&
+ (p[1] > this.pp.top-o.distance) &&
+ (p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
if (!overlap) { return false; }
for (var i=0; i<this.items.length; i++) {
c = this.items[i];
var olddistance = distance;
- if(!o.axis) {
+ if (!o.axis) {
distance = Math.sqrt(
Math.pow(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2), 2)
+ Math.pow(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)
@@ -117,11 +121,11 @@ $.widget("ui.magnifier", { distance = Math.abs(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2));
} else {
distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));
- }
+ }
}
if (distance < o.distance) {
- this.current = distance < olddistance ? this.items[i] : this.current;
+ this.current = distance < olddistance ? c : this.current;
if (!o.axis || o.axis != "y") {
$(c[0]).css({
@@ -134,7 +138,7 @@ $.widget("ui.magnifier", { $(c[0]).css({
height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),
top: (c[3] ? c[3].top : 0) + (o.baseline-0.5) * ((c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)))
- });
+ });
}
if (o.opacity) {
@@ -154,9 +158,8 @@ $.widget("ui.magnifier", { (o.zIndex && $(c[0]).css("z-index", ""));
}
- (this.options.zIndex &&
- $(this.current[0]).css("z-index", this.options.zIndex));
- }
+ (o.zIndex && $(this.current[0]).css("z-index", o.zIndex));
+ }
});
$.extend($.ui.magnifier, {
|