限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

javascript鼠标点击触发显示多彩圆球粒子动画特效

所属分类: 网页特效-动画效果    2024-01-03 09:38:13

javascript鼠标点击触发显示多彩圆球粒子动画特效 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

javascript鼠标点击触发显示多彩圆球粒子动画特效(共3个文件)

    • index.html

使用方法

  • code
  • source
  1. // click event listener
  2. $('.particle__container').on('click', function(e) {
  3. explode(e.pageX, e.pageY);
  4. })
  5. // explosion construction
  6. function explode(x, y) {
  7. var particles = 15,
  8. // explosion container and its reference to be able to delete it on animation end
  9. explosion = $('<div class="explosion"></div>');
  10. // put the explosion container into the body to be able to get it's size
  11. $('body').append(explosion);
  12. // position the container to be centered on click
  13. explosion.css('left', x - explosion.width() / 2);
  14. explosion.css('top', y - explosion.height() / 2);
  15. for (var i = 0; i < particles; i++) {
  16. // positioning x,y of the particle on the circle (little randomized radius)
  17. var x = (explosion.width() / 2) + rand(80, 150) * Math.cos(2 * Math.PI * i / rand(particles - 10, particles + 10)),
  18. y = (explosion.height() / 2) + rand(80, 150) * Math.sin(2 * Math.PI * i / rand(particles - 10, particles + 10)),
  19. color = rand(0, 255) + ', ' + rand(0, 255) + ', ' + rand(0, 255), // randomize the color rgb
  20. // particle element creation (could be anything other than div)
  21. elm = $('<div class="particle" style="' +
  22. 'background-color: rgb(' + color + ') ;' +
  23. 'top: ' + y + 'px; ' +
  24. 'left: ' + x + 'px"></div>');
  25. if (i == 0) { // no need to add the listener on all generated elements
  26. // css3 animation end detection
  27. elm.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
  28. explosion.remove(); // remove this explosion container when animation ended
  29. });
  30. }
  31. explosion.append(elm);
  32. }
  33. }
  34. // get random number between min and max value
  35. function rand(min, max) {
  36. return Math.floor(Math.random() * (max + 1)) + min;
  37. }
// click event listener
$('.particle__container').on('click', function(e) {
  explode(e.pageX, e.pageY);
})

// explosion construction
function explode(x, y) {
  var particles = 15,
    // explosion container and its reference to be able to delete it on animation end
    explosion = $('<div class="explosion"></div>');

  // put the explosion container into the body to be able to get it's size
  $('body').append(explosion);

  // position the container to be centered on click
  explosion.css('left', x - explosion.width() / 2);
  explosion.css('top', y - explosion.height() / 2);

  for (var i = 0; i < particles; i++) {
    // positioning x,y of the particle on the circle (little randomized radius)
    var x = (explosion.width() / 2) + rand(80, 150) * Math.cos(2 * Math.PI * i / rand(particles - 10, particles + 10)),
      y = (explosion.height() / 2) + rand(80, 150) * Math.sin(2 * Math.PI * i / rand(particles - 10, particles + 10)),
      color = rand(0, 255) + ', ' + rand(0, 255) + ', ' + rand(0, 255), // randomize the color rgb
        // particle element creation (could be anything other than div)
      elm = $('<div class="particle" style="' +
        'background-color: rgb(' + color + ') ;' +
        'top: ' + y + 'px; ' +
        'left: ' + x + 'px"></div>');

    if (i == 0) { // no need to add the listener on all generated elements
      // css3 animation end detection
      elm.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
        explosion.remove(); // remove this explosion container when animation ended
      });
    }
    explosion.append(elm);
  }
}

// get random number between min and max value
function rand(min, max) {
  return Math.floor(Math.random() * (max + 1)) + min;
}

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 动画效果

html5 canvas酷炫的菱角唯美背景动画特效

一款缤纷多彩颜色的背景动画,无规则随机图案特效,很好看!
  动画效果
 2381  0

javascript鼠标点击触发显示多彩圆球粒子动画特效

一款鼠标点击动画特效代码,圆球粒子是通过单击处理程序函数中的jQuery append方法附加的div元素进行构建。这个点击事件可以附加到任何DOM的html元素中,非常的漂亮。
  动画效果
 1734  0

vue产品左右展开收缩参数对比动画特效代码

一款产品信息左右推拉显示特效,三星手机和苹果手机参数对比,点击左右两边可展开当前手机参数信息。
  动画效果
 8264  0

html5 canvas绘制圆形气泡背景动画特效

一款由jq画布绘制的随机气泡背景动画,有点类似于雨滴花纹的感觉!
  动画效果
 4442  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论