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;
|
var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
|
||||||
this.current = this.items[0];
|
this.current = this.items[0];
|
||||||
|
|
||||||
//Compute the parents distance, because we don't need to fire anything if we are not near the parent
|
// Compute the parent's distance
|
||||||
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));
|
// 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; }
|
if (!overlap) { return false; }
|
||||||
|
|
||||||
for (var i=0; i<this.items.length; i++) {
|
for (var i=0; i<this.items.length; i++) {
|
||||||
c = this.items[i];
|
c = this.items[i];
|
||||||
|
|
||||||
var olddistance = distance;
|
var olddistance = distance;
|
||||||
if(!o.axis) {
|
if (!o.axis) {
|
||||||
distance = Math.sqrt(
|
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[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)
|
+ Math.pow(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)
|
||||||
@ -121,7 +125,7 @@ $.widget("ui.magnifier", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (distance < o.distance) {
|
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") {
|
if (!o.axis || o.axis != "y") {
|
||||||
$(c[0]).css({
|
$(c[0]).css({
|
||||||
@ -154,8 +158,7 @@ $.widget("ui.magnifier", {
|
|||||||
(o.zIndex && $(c[0]).css("z-index", ""));
|
(o.zIndex && $(c[0]).css("z-index", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
(this.options.zIndex &&
|
(o.zIndex && $(this.current[0]).css("z-index", o.zIndex));
|
||||||
$(this.current[0]).css("z-index", this.options.zIndex));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user