Jet-Run is a 3D Endless Runner game template where you control a jet-skin, dodging obstacles and collecting coins. Web Dev { switch (text_5.textContent) { case "Loading . .": text_5.textContent = "Loading . . ."; break; case "Loading .": text_5.textContent = "Loading . ."; break; default: text_5.textContent = "Loading ."; break; } }, 500); } let isLoad = true; function gameLoader() { if (isLoad) { isLoad = false; const iframe = document.getElementById('iframe1'); iframe.style.display = 'block'; document.body.style.overflow = "auto"; const backLink = document.createElement('a'); backLink.href = "https://journeyplay.top"; backLink.className = "back-icon"; backLink.id = "backButton"; const img = document.createElement('img'); img.src = "/static/images/home-2.png"; img.style.width = "38px"; img.style.height = "38px"; backLink.appendChild(img); document.getElementById('gameIframe').appendChild(backLink); // 初始化拖动功能 initDragAndSnap(backLink); if (timer) clearInterval(timer); } } function initDragAndSnap(element) { let isDragging = false; let hasMoved = false; let startX = 0; let startY = 0; let initialX = 0; let initialY = 0; let xOffset = 0; let yOffset = 0; const snapThreshold = 30; const moveThreshold = 5; const savedPosition = localStorage.getItem('backButtonPosition'); if (savedPosition) { try { const pos = JSON.parse(savedPosition); xOffset = pos.x || 0; yOffset = pos.y || 0; element.style.left = xOffset + 'px'; element.style.top = yOffset + 'px'; } catch (e) { console.error('Failed to parse saved position:', e); } } element.addEventListener('touchstart', handleStart, { passive: false }); element.addEventListener('touchend', handleEnd, { passive: false }); element.addEventListener('touchmove', handleMove, { passive: false }); element.addEventListener('click', function (e) { if (hasMoved) { e.preventDefault(); e.stopPropagation(); } }); function handleStart(e) { if (!e.touches) return; const touch = e.touches[0]; startX = touch.clientX - xOffset; startY = touch.clientY - yOffset; initialX = xOffset; initialY = yOffset; isDragging = true; hasMoved = false; element.classList.add('dragging'); element.style.transition = 'none'; e.preventDefault(); } function handleMove(e) { if (!isDragging || !e.touches) return; const touch = e.touches[0]; const newX = touch.clientX - startX; const newY = touch.clientY - startY; const maxX = window.innerWidth - element.offsetWidth; const maxY = window.innerHeight - element.offsetHeight; xOffset = Math.max(0, Math.min(newX, maxX)); yOffset = Math.max(0, Math.min(newY, maxY)); if (Math.abs(xOffset - initialX) > moveThreshold || Math.abs(yOffset - initialY) > moveThreshold) { hasMoved = true; } element.style.left = xOffset + 'px'; element.style.top = yOffset + 'px'; e.preventDefault(); } function handleEnd(e) { if (!isDragging || !e.touches) return; isDragging = false; element.classList.remove('dragging'); element.style.transition = 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)'; snapToEdge(element); if (!hasMoved) { setTimeout(() => { window.location.href = element.href; }, 150); } e.preventDefault(); } function snapToEdge(el) { const rect = el.getBoundingClientRect(); const windowWidth = window.innerWidth; const elWidth = rect.width; // 根据当前位置,始终吸附到左边或右边 const centerX = rect.left + elWidth / 2; const windowCenterX = windowWidth / 2; let finalX; if (centerX <= windowCenterX) { // 更靠左,吸附到左侧 finalX = 0; } else { // 更靠右,吸附到右侧 finalX = windowWidth - elWidth; } el.style.left = finalX + 'px'; xOffset = finalX; try { localStorage.setItem('backButtonPosition', JSON.stringify({ x: finalX, y: yOffset })); } catch (e) { console.error('Failed to save position:', e); } } }