hexo-next 增加鼠标点击特效

  • 时间:2020-04-24 21:08 作者:Frank1901s 来源: 阅读:1173
  • 扫一扫,手机访问
摘要:鼠标点击显示小心心的特效很多博客都有,今天有时间也试了试,简单记录如下:1. 创立实现该功能的js文件在…\themes\hexo theme next\source\js\my_js下新建clicklove.js文件,source后面的路径和文件名都可以自己设置,内容如下:/*网页鼠标点击特效(爱心

鼠标点击显示小心心的特效很多博客都有,今天有时间也试了试,简单记录如下:

1. 创立实现该功能的js文件

…\themes\hexo-theme-next\source\js\my_js下新建clicklove.js文件,source后面的路径和文件名都可以自己设置,内容如下:

/*网页鼠标点击特效(爱心)*/!function (e, t, a) {function r() {for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");requestAnimationFrame(r)}function n() {var t = "function" == typeof e.onclick && e.onclick;e.onclick = function (e) {t && t(), o(e)}}function o(e) {var a = t.createElement("div");a.className = "heart", s.push({el: a,x: e.clientX - 5,y: e.clientY - 5,scale: 1,alpha: 1,color: c()}), t.body.appendChild(a)}function i(e) {var a = t.createElement("style");a.type = "text/css";try {a.appendChild(t.createTextNode(e))} catch (t) {a.styleSheet.cssText = e}t.getElementsByTagName("head")[0].appendChild(a)}function c() {return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"}var s = [];e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {setTimeout(e, 1e3 / 60)}, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()}(window, document);
文件路径

2. 配置及启用

2.1 在配置文件中引入新建的js文件

…\themes\hexo-theme-next\layout*路径下找到“_layout.swig”*文件,在<head></head>标签中引入新建的js文件,代码如下:

 <script type="text/javascript" src="/js/my_js/clicklove.js"></script>

配置文件路径一及修改配置的界面如下:

配置文件路径修改部分展现

2.2 升级同步配置

使用hexo g命令生成,使用hexo s命令部署在本地,默认情况下通过访问localhost:4000即可以查看到效果。之后通过hexo d -g推送至github就可。

3. 测试效果展现

鼠标点击小心心预览效果

本文作者原创,转载请注明出处!

<center>秋风木叶</center>
<center>2020-4-20</center>

  • 全部评论(0)
最新发布的资讯信息
【系统环境|】2FA验证器 验证码如何登录(2024-04-01 20:18)
【系统环境|】怎么做才能建设好外贸网站?(2023-12-20 10:05)
【系统环境|数据库】 潮玩宇宙游戏道具收集方法(2023-12-12 16:13)
【系统环境|】遥遥领先!青否数字人直播系统5.0发布,支持真人接管实时驱动!(2023-10-12 17:31)
【系统环境|服务器应用】克隆自己的数字人形象需要几步?(2023-09-20 17:13)
【系统环境|】Tiktok登录教程(2023-02-13 14:17)
【系统环境|】ZORRO佐罗软件安装教程及一键新机使用方法详细简介(2023-02-10 21:56)
【系统环境|】阿里云 centos 云盘扩容命令(2023-01-10 16:35)
【系统环境|】补单系统搭建补单源码搭建(2022-05-18 11:35)
【系统环境|服务器应用】高端显卡再度登上热搜,竟然是因为“断崖式”的降价(2022-04-12 19:47)
手机二维码手机访问领取大礼包
返回顶部