// dom111.co.uk
function Parallax(a) { if (!jQuery) { throw new Error("Missing jQuery!") } var a = jQuery.extend({ container: "div.parallax", useHTML: true, elements: [] }, a || {}); jQuery((a.useHTML) ? "html" : a.container).mousemove(function (j) { var f = jQuery(this); var c = { x: Math.floor(parseInt(f.width()) / 2), y: Math.floor(parseInt(f.height()) / 2) }; var k = { x: (j.pageX - f.offset().left), y: (j.pageY - f.offset().top) }; var g = { x: (k.x - c.x), y: (k.y - c.y) }; for (var h = a.elements.length - 1; h >= 0; h--) { var b = {}, l, d; for (var m in a.elements[h].properties.x) { d = a.elements[h].properties.x[m]; l = d.initial + (g.x * d.multiplier); if (d.min && l < d.min) { l = d.min } else { if (d.max && l > d.max) { l = d.max } } b[m] = l } for (var m in a.elements[h].properties.y) { d = a.elements[h].properties.y[m]; l = d.initial + (g.y * d.multiplier); if (d.min && l < d.min) { l = d.min } else { if (d.max && l > d.max) { l = d.max } } b[m] = l } if ("background-position-x" in b || "background-position-y" in b) { b["background-position"] = "" + ((b["background-position-x"]) ? b["background-position-x"] : "0") + "px " + ((b["background-position-y"]) ? b["background-position-y"] : "0") + "px"; delete b["background-position-x"]; delete b["background-position-y"] } jQuery(a.elements[h].selector).css(b) } }) };
