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

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

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

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

    • index.html

使用方法

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

javascript带鼠标滑动控制的圆形进度滑块特效

一款环状进度滑块特效代码,用户可用交互方式选择圆形滑块内的范围。根据用户的鼠标拖动来计算所选范围,并更新显示相应数值。数值从0~100,圆中心数字颜色也从红色 - 黑色 - 绿色进行变换。
  动画效果
 85  

jquery轻量级无缝平滑滚动列表动画特效插件

一款带控制按钮的多功能列表滚动特效,还可设置自动滚动,很实用!
  动画效果
 169  

jquery前后叠加的卡片式点击动画交替显示特效代码

一款卡片交替动画特效,鼠标点击DIV卡片区域,自动触发两张卡片交替轮换显示,一个在最上层,另一个在最下层被覆盖。
  动画效果
 118  

jquery单页自定义全屏滚动页面插件

Scrollify是一个页面滚动插件,可提醒用户使用鼠标滚轮或拉动滚动条,进行滚动页面。
  动画效果
 129  

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

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