WIKI公告栏
欢迎各位引航者访问卡拉彼丘WIKI,由于游客访问页面会有一定的页面旧版缓存,建议你登陆B站账号进行浏览,如果您觉得本WIKI有帮助到你,欢迎推荐给身边的引航者。
全站通知:

U:54212577/sortableTableAnimation.js

阅读

    

2024-05-05更新

    

最新编辑:鬼影233

阅读:

  

更新日期:2024-05-05

  

最新编辑:鬼影233

来自卡拉彼丘WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索
页面贡献者 :
鬼影233
"use strict";
(() => {
	window.sta ??= 350;
	const updateLastY = (tr, offsetTop) =>
		(tr.lastY = tr.offsetTop - offsetTop);
	[...document.body.querySelectorAll("table.sortable")].forEach(table => {
		const offsetTop = table.querySelector("tbody > tr").offsetTop;
		[...table.querySelectorAll("tbody > tr")].forEach(tr =>
			updateLastY(tr, offsetTop)
		);
		[...table.querySelectorAll("thead > tr > th.headerSort")].forEach(
			th => {
				th.onclick = () => {
					const trs = [...table.querySelectorAll("tbody > tr")];
					trs.forEach(tr => {
						const dis = tr.lastY - tr.offsetTop + offsetTop;
						tr.style.transition = "";
						tr.style.transform = `translateY(${dis}px)`;
					});
					trs.forEach(tr => {
						tr.style.transition = `transform ${window.sta}ms`;
						tr.style.transform = "";
						updateLastY(tr, offsetTop);
					});
				};
				const mwCollapsibleToggle = th.getElementsByClassName(
					"mw-collapsible-toggle"
				)[0];
				if (!mwCollapsibleToggle) return;
				mwCollapsibleToggle.onclick = () =>
					[...table.querySelectorAll("tbody > tr")].forEach(tr =>
						updateLastY(tr, offsetTop)
					);
			}
		);
		[...table.querySelectorAll("thead > tr")].forEach(tr => {
			if (getComputedStyle(tr).position !== "sticky") return;
			tr.style.zIndex = +getComputedStyle(tr).zIndex || 1;
		});
	});
})();