Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions assets/scss/_cursors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
.multi-cursor {
position: absolute;
pointer-events: none;
z-index: 10;
z-index: 9999;
width: 50px;
height: 50px;

top: 0;
left: 0;

img {
width: 100%;
height: auto;
Expand Down
6 changes: 4 additions & 2 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ <h4>Supported Technologies</h4>
</div>
</div>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.13.0/gsap.min.js" integrity="sha512-NcZdtrT77bJr4STcmsGAESr06BYGE8woZdSdEgqnpyqac7sugNO+Tr4bGwGF3MsnEkGKhU2KL2xh6Ec+BqsaHA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="/scripts/main.js" defer></script>
<script src="/scripts/hero-glass.js"></script>
<script src="/scripts/multi-player-cursors.js?v={{ now.Unix }}"></script>
<script src="/scripts/main.js" defer></script>
14 changes: 8 additions & 6 deletions layouts/partials/section/hero-glass.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ <h1>Infrastructure as Design</h1>
</div>
<div class="stats">
<a class="ghost subtle" href="https://cloud.layer5.io/catalog">
<div class="stat glass-mini">
<span class="stat-value">500+</span>
<span class="stat-label">Patterns</span>
</div>
<div class="stat glass-mini">
<span class="stat-value">500+</span>
<span class="stat-label">Patterns</span>
</div>
</a>
<div class="stat glass-mini">
<span class="stat-value">1-click</span>
Expand All @@ -40,6 +40,8 @@ <h1>Infrastructure as Design</h1>

<div class="hero-visual">
<div class="canvas-preview glass--dark" data-float>
<div class="cursor-layer" data-cursors="0,1,2,3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reduce the z-index to 10? 15?

Please ensure that only one copy of each cursor is visible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for points out the mistake. I have fixed the duplicate error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style="position:absolute; inset:0; z-index:9999; pointer-events:none;"></div>
<div class="canvas-header">
<span>Production</span>
<span class="status">Syncing</span>
Expand Down Expand Up @@ -72,5 +74,5 @@ <h3>Instant Docs</h3>
</div> -->
</div>
</section>
<script src="/scripts/hero-glass.js"></script>
<script src="/scripts/multi-player-cursors.js"></script>
<script src="/scripts/hero-glass.js"></script>
<script src="/scripts/multi-player-cursors.js"></script>
40 changes: 22 additions & 18 deletions static/scripts/multi-player-cursors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
const ANIMATION_DURATION = 3000; // 3 seconds
const ANIMATION_INTERVAL = 6000; // 6 seconds between movements
const CURSOR_SIZE = 50; // Default cursor size in pixels
const EDGE_PADDING = 500; // Padding from container edges
const EDGE_PADDING = 50; // Padding from container edges

/**
* Initialize cursors in a container
Expand All @@ -26,18 +26,18 @@
if (!container) return;

const cursors = [];

cursorIndices.forEach((index, i) => {
if (index >= CURSORS.length) return;

const cursorData = CURSORS[index];
const cursorElement = createCursorElement(cursorData);
container.appendChild(cursorElement);
cursors.push(cursorElement);

// Set initial random position
setInitialRandomPosition(container, cursorElement);

// Start animation with stagger
setTimeout(() => {
animateCursor(container, cursorElement);
Expand All @@ -51,11 +51,11 @@
clearInterval(intervalId);
return;
}

cursors.forEach((cursor, i) => {
// Check if cursor still exists
if (!document.body.contains(cursor)) return;

setTimeout(() => {
animateCursor(container, cursor);
}, i * ANIMATION_DURATION);
Expand All @@ -69,13 +69,13 @@
function createCursorElement(cursorData) {
const wrapper = document.createElement('div');
wrapper.className = 'multi-cursor';

const img = document.createElement('img');
img.src = cursorData.src;
img.alt = cursorData.name;

wrapper.appendChild(img);

return wrapper;
}

Expand All @@ -84,11 +84,15 @@
*/
function getRandomPosition(container) {
const rect = container.getBoundingClientRect();
const maxX = Math.max(10, rect.width - CURSOR_SIZE - EDGE_PADDING);
const maxY = Math.max(0, rect.height - CURSOR_SIZE - EDGE_PADDING);
const width = rect.width;
const height = rect.height;

const maxX = Math.max(10, width - CURSOR_SIZE - EDGE_PADDING);
const maxY = Math.max(10, height - CURSOR_SIZE - EDGE_PADDING);

const randomX = Math.floor(Math.random() * maxX);
const randomY = Math.floor(Math.random() * maxY)+600;
const randomY = Math.floor(Math.random() * maxY);

return { x: randomX, y: randomY };
}

Expand All @@ -105,10 +109,10 @@
*/
function animateCursor(container, element) {
const pos = getRandomPosition(container);

element.style.transition = `transform ${ANIMATION_DURATION}ms ease`;
element.style.transform = `translate(${pos.x}px, ${pos.y}px)`;

// Clear transition after animation completes
setTimeout(() => {
element.style.transition = '';
Expand All @@ -121,13 +125,13 @@
function init() {
// Find all containers with data-cursors attribute
const containers = document.querySelectorAll('[data-cursors]');

containers.forEach(container => {
const cursorIndices = container.getAttribute('data-cursors')
.split(',')
.map(i => parseInt(i.trim(), 10))
.filter(i => !isNaN(i));

if (cursorIndices.length > 0) {
initCursors(container, cursorIndices);
}
Expand Down