MCPcopy Index your code
hub / github.com/su-kaka/gcli2api / updateTabSlider

Function updateTabSlider

front/common.js:917–942  ·  view source on GitHub ↗
(targetTab, animate = true)

Source from the content-addressed store, hash-verified

915
916// 更新滑块位置
917function updateTabSlider(targetTab, animate = true) {
918 const slider = document.querySelector('.tab-slider');
919 const tabs = document.querySelector('.tabs');
920 if (!slider || !tabs || !targetTab) return;
921
922 // 获取按钮位置和容器宽度
923 const tabLeft = targetTab.offsetLeft;
924 const tabWidth = targetTab.offsetWidth;
925 const tabsWidth = tabs.scrollWidth;
926
927 // 使用 left 和 right 同时控制,确保动画同步
928 const rightValue = tabsWidth - tabLeft - tabWidth;
929
930 if (animate) {
931 slider.style.left = `${tabLeft}px`;
932 slider.style.right = `${rightValue}px`;
933 } else {
934 // 首次加载时不使用动画
935 slider.style.transition = 'none';
936 slider.style.left = `${tabLeft}px`;
937 slider.style.right = `${rightValue}px`;
938 // 强制重绘后恢复过渡
939 slider.offsetHeight;
940 slider.style.transition = '';
941 }
942}
943
944// 初始化滑块位置
945function initTabSlider() {

Callers 3

initTabSliderFunction · 0.85
common.jsFile · 0.85
switchTabFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected