-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
131 lines (109 loc) · 3.84 KB
/
Copy pathscript.js
File metadata and controls
131 lines (109 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Custom cursor
const cursor = document.getElementById("cursor")
const cursorBlur = document.getElementById("cursor-blur")
document.addEventListener("mousemove", (e) => {
cursor.style.left = e.clientX + "px"
cursor.style.top = e.clientY + "px"
cursorBlur.style.left = e.clientX - 200 + "px"
cursorBlur.style.top = e.clientY - 200 + "px"
})
// Theme toggle
const themeToggle = document.getElementById("theme-toggle-checkbox")
const body = document.body
themeToggle.addEventListener("change", () => {
body.classList.toggle("dark-theme")
})
// Mobile menu toggle
const burger = document.querySelector(".burger")
const nav = document.querySelector(".nav-links")
const navLinks = document.querySelectorAll(".nav-links li")
burger.addEventListener("click", () => {
nav.classList.toggle("nav-active")
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = ""
} else {
link.style.animation = navLinkFade 0.5s ease forwards ${index / 7 + 0.3}s
}
})
burger.classList.toggle("toggle")
})
// Smooth scrolling
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
e.preventDefault()
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
})
})
})
// Parallax effect
window.addEventListener("scroll", () => {
const parallaxElements = document.querySelectorAll(".parallax-section")
parallaxElements.forEach((element) => {
const speed = element.dataset.speed || 0.5
element.style.backgroundPositionY = -(window.pageYOffset * speed) + "px"
})
})
// Package slider
const slider = document.querySelector(".package-slider")
const prevBtn = document.querySelector(".prev-btn")
const nextBtn = document.querySelector(".next-btn")
prevBtn.addEventListener("click", () => {
slider.scrollBy({ left: -300, behavior: "smooth" })
})
nextBtn.addEventListener("click", () => {
slider.scrollBy({ left: 300, behavior: "smooth" })
})
// Form submission
const form = document.getElementById("contact-form")
form.addEventListener("submit", (e) => {
e.preventDefault()
// Here you would typically send the form data to a server
alert("Thank you for your message! We will get back to you soon.")
form.reset()
})
// Intersection Observer for fade-in animations
const faders = document.querySelectorAll(".fade-in")
const appearOptions = {
threshold: 0.5,
rootMargin: "0px 0px -100px 0px",
}
const appearOnScroll = new IntersectionObserver((entries, appearOnScroll) => {
entries.forEach((entry) => {
if (!entry.isIntersecting) {
return
} else {
entry.target.classList.add("appear")
appearOnScroll.unobserve(entry.target)
}
})
}, appearOptions)
faders.forEach((fader) => {
appearOnScroll.observe(fader)
})
// 3D Background
import * as THREE from "three" // Import THREE.js library
const scene = new THREE.Scene()
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
const renderer = new THREE.WebGLRenderer({ alpha: true })
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
const geometry = new THREE.TorusGeometry(10, 3, 16, 100)
const material = new THREE.MeshBasicMaterial({ color: 0xff6b6b, wireframe: true })
const torus = new THREE.Mesh(geometry, material)
scene.add(torus)
camera.position.z = 30
function animate() {
requestAnimationFrame(animate)
torus.rotation.x += 0.01
torus.rotation.y += 0.005
renderer.render(scene, camera)
}
animate()
// Handle window resize
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight
camera.updateProjectionMatrix()
renderer.setSize(window.innerWidth, window.innerHeight)
})