magento effects.js jquery.lazyload.js 冲突

当这两个js并存时,会造成加载图片闪烁的冲突问题

原因:
jquery.lazyload.js会触发叫"appear"的显示效果,利用jQuery trigger()方法影响图片元素
effects.js中给元素模型添加了appear()方法
这样两个方法同时影响元素,改变透明度,就会造成闪烁

解决:
1.注释effects.js最后一句Element.addMethods(Effect.Methods);
或者改变Effect.Methods,去掉appear()
2.jquery.lazyload.js 替换appear为其他名字

原文
jquery.lazyload.js triggers an event called “appear” to show the effect and because of the way the jQuery trigger() method is written it will try and trigger a method on the element as well as trigger the event. The Effects methods in Scriptaculous add an appear() method to the Element prototype. The Scriptaculous appear() is firing as well as the lazyload fadeIn() and thats were you get a flicker when 2 methods are trying to change the opacity of the element at the same time.

How to fix it:
First Method
/root/js/scriptaculous/effects.js
In your copy of effects.js the last line is

Element.addMethods(Effect.Methods);

If you remove that line it will remove the Scriptaculous Effects methods from the Element prototype and should fix the immediate problem. However if any other plugins are depending on the Effects methods on the Element prototype they will start failing. But if you are using those methods you can change them over to use the anonymous methods. ie

$(‘myelement’).appear();
// changes to
Effect.Appear(‘myelement’);

Second method, i think this the easiest and secure way to remove the conflict and this method also not effect any existing effects.
In your copy of jquery.lazyload.js just replace the “appear” key word with appear1 or any other word, save file and enjoy the lazy load plugin.//成功解决


转载于:https://my.oschina.net/liufeng815/blog/389311

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值