
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
slider-controller
Advanced tools
The SliderController is a custom web component built using the LitElement library. It provides a slider functionality for a collection of SlideItem elements.
You can install the SliderController using npm.
npm install slider-controller
Then, you need to import the SliderController and SlideItem in your project.
import "slider-controller"
import "slide-item"
To use the SliderController, you need to include it in your HTML as a custom element. The SlideItem elements should be nested inside the SliderController.
<slider-controller>
<slide-item>Slide 1</slide-item>
<slide-item>Slide 2</slide-item>
<slide-item>Slide 3</slide-item>
<!-- Add more slide items as needed -->
</slider-controller>
Each SlideItem represents a single slide in the slider. You can put any content inside a SlideItem.
The SliderController automatically handles the scrolling behavior of the slides. It also emits custom events SLIDER_SCROLLING and SLIDER_SCROLLING_DONE which you can listen to for custom behavior.
| Method | Type | Description |
|---|---|---|
| next() | method | Slides to next slide-item |
| previous() | method | Slides to previous slide-item |
| Method | Type | Description |
|---|---|---|
| currentIndex | getter | Gets the current index of the active slider |
| totalItems | getter | Gets the total number of slide-items |
| hasPrevious | getter | Is there a previous slide-item? Good for disabling buttons fx. |
| hasNext | getter | Is there a next slide-item? Good for disabling buttons fx. |
| Event | Type | Description |
|---|---|---|
| SLIDER_SCROLLING | event | Fires on each DOM scroll event |
| SLIDER_SCROLLING_DONE | event | Fires after scroll is done |
The SliderController automatically cleans up its event listeners when it is disconnected from the DOM. You don't need to manually remove the event listeners.
The SliderController uses a debounced scroll and resize event to improve performance. The debounce delay is currently set to 300ms.
The SliderController component uses CSS variables for some of its styles, which you can override in your own CSS. Here's how you can do it:
--slider-controller-gap: This variable controls the gap between the slides. You can set it to any valid CSS length value. For example, to set the gap to 20px, you would do:slider-controller {
--slider-controller-gap: 20px;
}
--slider-controller-item-size: This variable controls the size of the slides. You can set it to any valid CSS length value. The default is auto meaning that the items retain their natural size. For example, to set the size to 200px, you would do:slider-controller {
--slider-controller-item-size: 200px;
}
Note that these variables should be set on the slider-controller element itself, not on the :host selector inside the slider-controller's CSS.
In addition to these variables, you can also apply any other CSS styles to the slider-controller element as you would with any other HTML element. However, keep in mind that due to the Shadow DOM, styles applied outside the slider-controller will not affect the internal elements of the slider-controller (like the .container div). If you need to style these internal elements, you would need to modify the slider-controller.css.ts file directly.
FAQs
CSS scroll-snap slider with control options
We found that slider-controller demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.