💄 Optimize comment components display style.

This commit is contained in:
凡梦星尘
2022-06-20 09:52:23 +08:00
parent f0ae834374
commit fae6b4787c
4 changed files with 33 additions and 8 deletions

View File

@@ -50,6 +50,7 @@ NexT.boot.refresh = function() {
NexT.utils.registerLangSelect();*/
NexT.utils.registerSidebarTOC();
NexT.utils.registerPostReward();
NexT.utils.initCommontesDispaly();
NexT.utils.registerCommonSwitch();
NexT.utils.wrapTableWithBox();
NexT.utils.registerVideoIframe();

View File

@@ -243,17 +243,29 @@ NexT.utils = {
});
},
initCommontesDispaly: function(){
const comms = document.querySelectorAll('.comment-wrap > div');
if (comms.length<=1) return;
comms.forEach(function(item){
var dis = window.getComputedStyle(item, null).display;
item.style.display = dis;
});
},
registerCommonSwitch: function() {
const button = document.querySelector('.comment-switch .switch-btn');
if (!button) return;
const cwrap = document.querySelector('.comment-wrap');
const comms = document.querySelectorAll('.comment-wrap > div');
button.addEventListener('click', () => {
button.classList.toggle('move');
const comms = document.querySelectorAll('.comment-wrap > div');
let len = comms.length;
while(len--){
cwrap.appendChild(comms[len]);
}
comms.forEach(function(item){
item.style.display = item.style.display === 'none' ? 'block' : 'none';
if (item.style.display === 'block') {
item.style.animation = "0.8s ease 0s 1 normal none running tabshow";
} else {
item.style.removeProperty('animation');
}
});
});
},