(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(/([-\.]+)(\s|\)|$)/g, "$1px$2");
var res = strg.match(/(-?[-\.]+)(px|\%|em|pt)\s(-?[-\.]+)(px|\%|em|pt)/);
return [parseFloat(res[], ), res[], parseFloat(res[], ), res[]];
} $.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[], start[]]; var end = toArray(fx.end);
fx.end = [end[], end[]]; fx.unit = [end[], end[]];
fx.bgPosReady = true;
} var nowPosX = [];
nowPosX[] = ((fx.end[] - fx.start[]) * fx.pos) + fx.start[] + fx.unit[];
nowPosX[] = ((fx.end[] - fx.start[]) * fx.pos) + fx.start[] + fx.unit[];
fx.elem.style.backgroundPosition = nowPosX[] + ' ' + nowPosX[];
};
})(jQuery);

调用示例:

//动画调用示例
$("#viewBody").animate({ backgroundPosition: '(520px 0)' });

最新文章

  1. 事件EVENT与waitforsingleobject的使用
  2. 【原】Github系列之三:开源iOS下 渐变颜色的进度条WGradientProgress
  3. C#-WinForm-用户控件如何获取父级窗体
  4. 探索javascript----this的指向问题
  5. BI先特技软件 Analyzer安装时的部分问题
  6. MSBI BigData demo—sqoop import
  7. tomcat server获取用户的请求地址
  8. Java GC 专家系列3:GC调优实践
  9. 使用ICE进程间通信时,IP和端口的选择
  10. CSS的display、hover、overflow、&copy(版权符号)、borer-radius(边框圆角)
  11. 【Java 它 JVM】对象的创建过程
  12. 如何用Python在豆瓣中获取自己喜欢的TOP N电影信息
  13. Flex设置LinkButton的背景色
  14. macOS卸载应用不彻底
  15. kali linux 使用笔记本快捷键调节音量
  16. mongooDb链接javaapi
  17. 弹出框sweetalert插件的简单使用
  18. [Aaronyang] 写给自己的WPF4.5 笔记8[复杂数据处理三步曲,数据视图精讲1/3]
  19. Chrome Extension 实战
  20. 【转】在SpringMVC Controller中注入Request成员域

热门文章

  1. (1)ansible基本配置
  2. Druid 架构
  3. 【ASP.NET】必须知道的ASP.NET核心处理
  4. Codeforces 429 B. Working out-dp( Codeforces Round #245 (Div. 1))
  5. 【数据结构】 最小生成树(二)——kruskal算法
  6. python 字符串,数学之间的不可描述的关系
  7. START法则
  8. 「HNOI2013」游走
  9. BZOJ 2152 聪聪可可(点分治)
  10. 【动态规划】【滚动数组】【bitset】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem J. Terminal