mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-17 03:29:31 -07:00
feat(stage.ts): implement stage navigation functionality feat(stageNav.ts): implement stage navigation overlay functionality feat(state.ts): implement state management for index and threshold feat(utils.ts): add utility functions for increment and decrement
39 lines
973 B
TypeScript
39 lines
973 B
TypeScript
import { addActiveCallback } from './stage'
|
|
|
|
let cursor: HTMLDivElement
|
|
|
|
// create cursor
|
|
cursor = document.createElement('div')
|
|
cursor.className = 'cursor'
|
|
cursor.classList.add('active')
|
|
// create cursor inner
|
|
const cursorInner = document.createElement('div')
|
|
cursorInner.className = 'cursorInner'
|
|
// append cursor inner to cursor
|
|
cursor.append(cursorInner)
|
|
|
|
function onMouse(e: MouseEvent) {
|
|
const x = e.clientX
|
|
const y = e.clientY
|
|
cursor.style.transform = `translate3d(${x}px, ${y}px, 0)`
|
|
}
|
|
|
|
export function initCustomCursor(): void {
|
|
// append cursor to main
|
|
document.getElementById('main')!.append(cursor)
|
|
// bind mousemove event to window
|
|
window.addEventListener('mousemove', onMouse)
|
|
// add active callback
|
|
addActiveCallback((active) => {
|
|
if (active) {
|
|
cursor.classList.add('active')
|
|
} else {
|
|
cursor.classList.remove('active')
|
|
}
|
|
})
|
|
}
|
|
|
|
export function setCustomCursor(text: string): void {
|
|
cursorInner.innerText = text
|
|
}
|