# Selection JS
This library enables a custom selection effect when a user selects text inside specific elements. You can also trigger an optional animation when the user presses Ctrl+C to copy the selected content.



https://github.com/user-attachments/assets/ef423119-6afd-4fa4-b400-94299f475748
## Features
- Highlight effect using customizable colored overlays
- `CTRL` + `C` copy animations for specific elements
- Lightweight and styleable with CSS
- Works with dynamically added elements, as long as they exist before user selection
## Installation
1. Include the CSS in your HTML:
```HTML
```
2. Include the JavaScript file just before the closing `
Lorem ipsum with a custom CTRL + C animation. dolor sit amet, consectetur adipiscing elit. Nullam non urna vitae libero bibendum tincidunt.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam non urna vitae libero bibendum tincidunt.
Phasellus euismod, justo at scelerisque tincidunt, libero erat fermentum libero, nec tincidunt lorem arcu nec libero.
Phasellus euismod, justo at scelerisque tincidunt, libero erat fermentum libero, nec tincidunt lorem arcu nec libero.
function
on_copy_animation(SELECTION_COLOR, SELECTION_BOX_ELEMENT)
{
const ORG_LEFT = SELECTION_BOX_ELEMENT.style.left;
const ORG_TOP = SELECTION_BOX_ELEMENT.style.top;
const ORG_WIDTH = SELECTION_BOX_ELEMENT.style.width;
const ORG_HEIGHT = SELECTION_BOX_ELEMENT.style.height;
const RECT = SELECTION_BOX_ELEMENT.getBoundingClientRect();
SELECTION_BOX_ELEMENT.style.backgroundColor = "#FFF";
setTimeout(
function()
{
SELECTION_BOX_ELEMENT.style.backgroundColor = SELECTION_COLOR;
},
100
);
}
SOFT_SELECTION("#E84A8C");