可能有两个blur.js实例吗? [英] Two instances of blur.js possible?

查看:109
本文介绍了可能有两个blur.js实例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在具有不同来源的两个不同元素上使用blur.js.我该如何实现?

I would like to use blur.js on two different elements with different sources. How can I achieve that?

到目前为止,我的代码:

My code so far:

 $('.blurry1').blurjs({
      source: '.source1',
      cache: false, 
      radius: 10,
      debug: 1,
 });

 $('.blurry2').blurjs({
      source: '.source2',
      cache: false, 
      radius: 10,
      debug: 1,
 });

只有第二个功能可以正确执行.

Only the second function is executed correctly.

推荐答案

可以完成,但是有点麻烦,因为它依赖setTimeout函数来等待第一个blurjs函数完成.

It can be done but it’s a bit of a hack as it relies on the setTimeout function to wait until the first blurjs function has finished.

$('#blurry1').blurjs({
    source: 'body',
    radius: 30,
    overlay: 'rgba(0, 0, 0, .2)',
    cache: false
});

setTimeout(function() {
    $('#blurry2').blurjs({
        source: '#bg2',
        radius: 30,
        overlay: 'rgba(0, 0, 0, .2)',
        cache: false
    });
}, 1000);

这篇关于可能有两个blur.js实例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆