Skip to content

Add cursor-following light ball widget with smooth trailing effect #1593

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

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
20 changes: 20 additions & 0 deletions Service Portal Widgets/Mouse Effect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Cursor Light Ball Widget

This ServiceNow Service Portal widget creates a light blue, glowing "light ball" that follows the cursor with a smooth trailing effect. The light ball is offset slightly from the cursor and has a soft glow, giving a visually appealing effect on the page.

## Widget Components

### HTML
The widget contains a single `div` element representing the light ball.

### CSS
This contains the style for the `div` element in HTML

### Script
This function tracks the cursor's position and updates the light ball's position accordingly with a 10px offset. The mousemove event listener enables smooth, real-time cursor tracking.

## Installation
1. Add a new widget in ServiceNow and name it, for example, "Cursor Light Ball".
2. Copy the HTML, CSS, and JavaScript code provided into the respective sections of the widget.
3. Make sure you copy the JavaScript code in the Client Script section of the widget.
4. Save the widget, and add it to your Service Portal page to see the light ball effect.
1 change: 1 addition & 0 deletions Service Portal Widgets/Mouse Effect/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="light-ball"></div>
14 changes: 14 additions & 0 deletions Service Portal Widgets/Mouse Effect/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
api.controller=function($scope, $element) {
var lightBall = $element.find('.light-ball');

// Update the position of the light ball on mouse move
document.addEventListener('mousemove', function(event) {
var mouseX = event.pageX + 10; // Offset by 10px to the right
var mouseY = event.pageY + 10; // Offset by 10px to the bottom

// Apply the position to the light ball
lightBall.css({
transform: 'translate(' + (mouseX - 30) + 'px, ' + (mouseY - 30) + 'px)'
});
});
}
13 changes: 13 additions & 0 deletions Service Portal Widgets/Mouse Effect/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Light Ball Styling */
.light-ball {
position: fixed;
top: 0;
left: 0;
width: 60px;
height: 60px;
background-color: rgba(173, 216, 230, 0.8); /* Light blue with slight transparency */
border-radius: 50%;
filter: blur(25px); /* Creates a fuzzy glow effect */
pointer-events: none; /* Ensures it doesn't interfere with clicking */
transition: transform 0.5s ease; /* 500ms latency effect */
}
Loading