nineya / halo-theme-dream2.0

适配halo2.x的dream主题
MIT License
144 stars 33 forks source link

feat:新增一个文字上升的鼠标点击效果 #71

Closed mjsoftking closed 9 months ago

mjsoftking commented 9 months ago

你当前使用的 Halo 版本

2.10.2

你当前使用的 Dream 版本

1.1.1

描述一下此特性

js代码如下:

var a_idx = 0; jQuery(document).ready(function($) { $("body").click(function(e) { var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"); var $i = $("<span/>").text(a[a_idx]); a_idx = (a_idx + 1) % a.length; var x = e.pageX, y = e.pageY; let scrolly = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop; y = y - scrolly; $i.css({ "z-index": 999, "top": y - 20, "left": x, "position": "fixed", "font-weight": "bold", "color": /*"#ff6651" 随机颜色写法:*/ "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")" }); $("body").append($i); $i.animate({ "top": y - 180, "opacity": 0 }, 1500, function() { $i.remove(); });  }); });

效果参看博客: https://www.sw0.top

网上找的,可以作为主题自带,或者复制上述代码到定制主题 - 内嵌JS中并关闭主题中鼠标点击特效,避免显示多个点击效果。

附加信息

No response