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

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

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

HTML+CSS创建的平滑过渡的翻页动画特效代码

基于CSS3关键帧制作的翻页动画效果,适用于产品、摄影图片幻灯片或演示库非常有用。也可在个人作品集、博客上使用此特效。
  动画效果
 7680  0

jquery个人简介转换成漂亮的动画卡片特效代码

一款个人简介信息转换卡片式特效插件,默认展示大头像和姓名,点击按钮可动画切换到更详细的简介说明,带平滑的动画特效。
  动画效果
 1706  0

jquery文本文字洗牌动画特效代码

一款可自定义的文本动画插件,6个位数,从左到右取随机数,过程类似于抽奖号码。
  动画效果
 5703  0

7个CSS创建的悬停动画特效代码

一款纯CSS实现的悬停按钮动画,以不同的方向填充按钮背景。而且,还有按钮内的图标显示悬停事件上的滑入和滑出动画。
  动画效果
 6964  0

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

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