火狐不支持backgroundPosition的js插件
2014-06-06 11:07
274 查看
用js backgroundPositionX,backgroundPositionY设置在firefox下无法识别,用backgroundPosition同样在火狐无法识别。 要识别只能用js插件来实现的,代码如下:
/** * @author Alexander Farkas * v. 1.02 */ (function($) { $.extend($.fx.step,{ backgroundPosition: function(fx) { if (fx.state === 0 && typeof fx.end == 'string') { var start = $.curCSS(fx.elem,'backgroundPosition'); 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]]; } 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]; 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]]; } } }); })(jQuery);用法加一个jq库和这个插件$(".bgpos").animate({backgroundPosition:"(-20px 94px)"},300);$(".bgpos").css({backgroundPosition: "-20px 35px"});如果定义一个变量方法如下:var a=9;$(".bgpos").animate({backgroundPosition:0+' '+a},300);
相关文章推荐
- 关于让火狐3.0.X支持迅雷下载插件的办法
- Eclipse的js插件Spket工具使用 支持主流ajax框架如ext等,silverlight,flex等
- eclipse下安装js插件-spket(支持Ext)
- js兼容ie和火狐支持获取图片大小和显示
- js兼容ie和火狐支持获取图片大小和显示
- eclipse下安装js插件-spket(支持Ext)
- 借鉴火狐 新版OpenOffice将支持插件开发
- js 日期控件 无插件,支持中英文,设置起止日期
- eclipse下安装js插件:spket(支持Ext编辑)
- css和js支持ie却不支持火狐的情况
- 火狐js调试插件venkman使用
- Eclipse Javascript插件,像写Java一样写JS —— Spket,支持ExtJS
- js无间断滚动新闻js.支持火狐和IE
- Eclipse Javascript插件,像写Java一样写JS —— Spket,支持ExtJS
- js 无插件选项卡 支持自动改变选中项
- jquery.select.js (下拉框插件)不支持IE6 的 方法 (小心用JQuery 插件)
- js 复制到剪贴板 ,兼容支持火狐firefox 和 ie
- JS的灯箱插件Shadowbox,支持图片、视频、网页、flash、FLV等媒体轮播
- eclipse下安装js插件-spket(支持Ext)
- jquery.form.js官方插件介绍Form插件,支持Ajax,支持Ajax文件上传