Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom cursor added (issue : #772) #836

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<body style="background-color: var(--secondary-color);">

<body>

<div class="dot"></div>
<div id="pre-loader">
<h1>TourGuide . . .</h1>
</div>
Expand Down Expand Up @@ -168,6 +168,7 @@ <h1>TourGuide . . .</h1>
<button id="toggle" data-aos="fade-down">Dark Theme</button>
<a href="#contact"><button class="btn" id="btn-style">Contact Us</button></a>
</nav> -->

<div class="nav-container" id="top">
<nav class="newNav">
<img src="./img/A T logo with a white background and a square shape, connected to nature for a travel company.png" style="width:30px;height:30px;border-radius:50%;">
Expand Down Expand Up @@ -603,6 +604,42 @@ <h2 class="section__title">Best trip packages</h2>
crossorigin="anonymous"></script>
<script src="jquery.flipster.min.js"></script>
<script>
// Custom Cursor
const dots = [];
const cursor = {
x: 0,
y: 0,
};

for (let i = 0; i < 10; i++) {
const dot = document.createElement("div");
dot.style.scale=`0.${10-(i)}`;
dot.className = "dot";
document.body.appendChild(dot);
dots.push(dot);
}

document.addEventListener("mousemove", (e) => {
cursor.x = e.clientX;
cursor.y = e.clientY;
});

function draw() {
let x = cursor.x;
let y = cursor.y;

dots.forEach((dot, index) => {
const nextDot = dots[index + 1] || dots[0];

dot.style.left = x + "px";
dot.style.top = y + "px";

x += (nextDot.offsetLeft - dot.offsetLeft) * 0.5;
y += (nextDot.offsetTop - dot.offsetTop) * 0.5;
});
}

setInterval(draw, 10);
$('.carousel').flipster({
style:'carousel',
spacing: -0.3,
Expand Down
4 changes: 2 additions & 2 deletions mouseEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ document.addEventListener('mousemove', function(event) {
ripple.className = 'ripple';
let relativeX = x + scrollLeft;
let relativeY = y + scrollTop;
ripple.style.left = `${relativeX - 5}px`;
ripple.style.top = `${relativeY - 5}px`;
ripple.style.left = `${relativeX - 1}px`;
ripple.style.top = `${relativeY - 12}px`;

document.body.appendChild(ripple);

Expand Down
17 changes: 17 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
}

body {
cursor: none;
display: flex;
justify-content: center;
align-items: center;
Expand Down Expand Up @@ -713,6 +714,7 @@ header {
/* Newsletter Modal */

.modal-container {
cursor: auto;
display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -2450,3 +2452,18 @@ body {
margin: 0 auto; /* Center the subtitle */
}
}
/* Custom Cursor */

.dot {
width: 30px;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
background: rgb(112, 224, 222);
position: fixed;
border-radius: 50%;
pointer-events: none;
transform: translate(-50%, -50%);
}

Loading