💄 Add tool button click events make it more silky.

This commit is contained in:
凡梦星尘
2022-10-06 10:48:52 +08:00
parent 0abad2539a
commit 0536ac37fc
3 changed files with 27 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ NexT.boot.registerEvents = function() {
NexT.utils.registerScrollPercent();
// NexT.utils.registerCanIUseTag();
NexT.utils.registerToolButtons();
// Mobile top menu bar.
document.querySelector('.site-nav-toggle .toggle').addEventListener('click', event => {

View File

@@ -23,6 +23,28 @@ HTMLElement.prototype.wrap = function(wrapper) {
NexT.utils = {
registerToolButtons: function() {
const comms_offset = document.getElementById('comments').getBoundingClientRect().top + window.scrollY;
document.getElementById('goto-comments').addEventListener('click', () => {
window.anime({
targets : document.scrollingElement,
duration : 500,
easing : 'linear',
scrollTop: comms_offset
});
});
const gt_offset = document.getElementById('google_translate_element').getBoundingClientRect().top + window.scrollY;
document.getElementById('goto-gt').addEventListener('click', () => {
window.anime({
targets : document.scrollingElement,
duration : 500,
easing : 'linear',
scrollTop: gt_offset
});
});
},
regSwitchThemeBtn: function() {
const switchThemeBtn = document.getElementById('switch-theme');
if (!switchThemeBtn) return;