mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Magnifier: Partial cleanup.
This commit is contained in:
parent
c2ce22addf
commit
6cfb6208ee
@ -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, {
|
||||
|
Loading…
Reference in New Issue
Block a user