MediaWiki:Common.js:修订间差异

来自NeuroWiki
跳转到导航 跳转到搜索
无编辑摘要
标签已被回退
撤销Selfice讨论)的修订版本128
标签替换 撤销
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
const container = document.getElementById('Homepage_scrollContainer');
let scrollInterval;
function startScrolling() {
  const items = document.querySelectorAll('.scroll-item');
  scrollInterval = setInterval(() => {
    items.forEach(item => {
      const currentTransform = getComputedStyle(item).transform;
      const matrixValues = currentTransform.match(/matrix.*\((.+)\)/);
      const translateXValue = matrixValues ? parseFloat(matrixValues[1].split(', ')[4]) : 0;
      // Move item to the left
      item.style.transform = `translateX(${translateXValue - 1}px)`;
      // If item moves out of view, reset its position
      if (translateXValue <= -item.offsetWidth) {
        item.style.transform = `translateX(${container.offsetWidth}px)`;
      }
    });
  }, 10); // Adjust speed by changing the interval time
}
function stopScrolling() {
  clearInterval(scrollInterval);
}
// Start scrolling when the page loads
startScrolling();
// Stop scrolling on mouse over
container.addEventListener('mouseover', stopScrolling);
// Resume scrolling on mouse out
container.addEventListener('mouseout', startScrolling);

2024年10月30日 (三) 21:22的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */