(function ($) { if (!document.defaultview || !document.defaultview.getcomputedstyle) { var oldcurcss = jquery.curcss; jquery.curcss = function (elem, name, force) { if (name === 'background-position') { name = 'backgroundposition'; } if (name !== 'backgroundposition' || !elem.currentstyle || elem.currentstyle[name]) { return oldcurcss.apply(this, arguments); } var style = elem.style; if (!force && style && style[name]) { return style[name]; } return oldcurcss(elem, 'backgroundpositionx', force) + ' ' + oldcurcss(elem, 'backgroundpositiony', force); }; } var oldanim = $.fn.animate; $.fn.animate = function (prop) { if ('background-position' in prop) { prop.backgroundposition = prop['background-position']; delete prop['background-position']; } if ('backgroundposition' in prop) { prop.backgroundposition = '(' + prop.backgroundposition + ')'; } return oldanim.apply(this, arguments); }; function toarray(strg) { strg = strg.replace(/left|top/g, '0px'); strg = strg.replace(/right|bottom/g, '100%'); strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g, "$1px$2"); var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/); return [parsefloat(res[1], 10), res[2], parsefloat(res[3], 10), res[4]]; } $.fx.step.backgroundposition = function (fx) { if (!fx.bgposready) { var start = $.curcss(fx.elem, 'backgroundposition'); if (!start) {//ff2 no inline-style fallback start = '0px 0px'; } start = toarray(start); fx.start = [start[0], start[2]]; var end = toarray(fx.end); fx.end = [end[0], end[2]]; fx.unit = [end[1], end[3]]; fx.bgposready = true; } var nowposx = []; nowposx[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0]; nowposx[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1]; fx.elem.style.backgroundposition = nowposx[0] + ' ' + nowposx[1]; }; })(jquery);