Loading…
RariaSense is a powerful tool that enables precise mouse tracking to enhance user interaction and engagement on web applications. With simple integration and intuitive functionality, developers can gain insights into user behavior and improve the overall user experience.
RariaSense is a lightweight and powerful JavaScript library designed to enhance web experiences by adding interactive sound effects triggered by mouse hover over HTML elements. This library is perfect for creating immersive and engaging web interfaces.
data-* attributes.refresh() method.<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>RariaSense Demo</title>
</head>
<body>
<button class="raria-item" data-sound="hover.mp3">
Hover Over Me
</button>
<script src="rariasense.js"></script>
<script>
new RariaSense({
selector: ".raria-item",
volume: 0.6
});
</script>
</body>
</html>
const raria = new RariaSense(options);
| Option | Type | Default | Description |
|---|---|---|---|
selector | string | .raria-item | CSS selector for elements that will trigger sound on hover |
sound | string | "" | Default sound for elements without data-sound |
delay | number | 0 | Delay before sound playback in milliseconds |
volume | number | 1 | Global volume level (0 to 1) |
loop | boolean | false | Enables continuous sound looping |
stopOnLeave | boolean | true | Stops sound when the mouse leaves the element |
pauseOnHidden | boolean | true | Pauses sound when the browser tab is hidden |
Customize individual elements with data-* attributes:
<button
class="raria-item"
data-sound="sound.mp3"
data-delay="500">
Click Here
</button>
Updates the list of elements and reapplies settings, useful when adding dynamic elements.
raria.refresh();
const raria = new RariaSense({
selector: ".item",
volume: 0.5 // Global volume
});
// Set specific volumes for individual elements
document.querySelectorAll(".item").forEach(el => {
if (el._rariaAudio) {
el._rariaAudio.volume = 0.8; // Specific volume for this item
}
});
const items = document.querySelectorAll(".raria-item");
// Play sound of a specific element
const audio = items[0]._rariaAudio;
if (audio) audio.play();
No comments yet.
Sign in to be the first to comment.