Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
@splidejs/splide
Advanced tools
@splidejs/splide is a lightweight, flexible, and powerful JavaScript slider and carousel library. It provides a wide range of features to create responsive, touch-friendly, and customizable sliders and carousels for web applications.
Basic Slider
This code initializes a basic slider using the Splide library. The '.splide' selector targets the HTML element that will contain the slider, and the 'mount()' method sets up the slider.
const splide = new Splide('.splide');
splide.mount();
Autoplay
This code initializes a slider with autoplay functionality. The 'type' option is set to 'loop' to create an infinite loop of slides, and 'autoplay' is set to true to enable automatic sliding.
const splide = new Splide('.splide', {
type : 'loop',
autoplay: true,
});
splide.mount();
Custom Pagination
This code demonstrates how to create a custom pagination for the slider. The 'pagination' option is set to false to disable the default pagination, and a custom pagination element is created and mounted using the 'pagination:mounted' event.
const splide = new Splide('.splide', {
pagination: false,
});
splide.mount();
const pagination = document.createElement('ul');
pagination.className = 'splide__pagination';
splide.on('pagination:mounted', function (data) {
data.list = pagination;
});
Responsive Breakpoints
This code configures the slider to be responsive to different screen sizes. The 'breakpoints' option allows you to specify different settings for different screen widths. In this example, the slider will show 1 slide per page on screens smaller than 640px and 2 slides per page on screens smaller than 1024px.
const splide = new Splide('.splide', {
breakpoints: {
640: {
perPage: 1,
},
1024: {
perPage: 2,
},
},
});
splide.mount();
Swiper is a modern touch slider that is highly customizable and supports a wide range of features including vertical sliders, nested sliders, and parallax effects. It is similar to @splidejs/splide in terms of flexibility and ease of use, but it offers more advanced features and a larger community.
Slick Carousel is a popular and widely used carousel library that offers a variety of features such as lazy loading, autoplay, and responsive breakpoints. It is similar to @splidejs/splide in terms of functionality, but it has a larger user base and more extensive documentation.
Owl Carousel is a touch-enabled jQuery plugin that allows you to create responsive and customizable carousels. It is similar to @splidejs/splide in terms of providing a wide range of customization options, but it requires jQuery as a dependency.
Splide is a lightweight, powerful and flexible slider and carousel, written in pure JavaScript without any dependencies.
There are 3 ways to install the Splide on your site.
Only the NPM way is explained in the following steps. Visit this page for other methods.
$ npm install @splidejs/splide
<link rel="stylesheet" href="node_modules/@splidejs/splide/dist/css/splide.min.css">
<div id="splide" class="splide">
<div class="splide__track">
<ul class="splide__list">
<li class="splide__slide">Slide 01</li>
<li class="splide__slide">Slide 02</li>
<li class="splide__slide">Slide 03</li>
</ul>
</div>
</div>
import Splide from '@splidejs/splide';
new Splide( '#splide' ).mount();
Note that only the first element will be initialized even if using a class name.Pass an object to the second argument of the Splide
constructor:
new Splide( '#splide', {
type : 'loop',
perPage: 3,
} );
Or set a data-splide
attribute to a root element in a JSON format:
<div id="splide" class="splide" data-splide="{"type":"loop","perPage":3}">
</div>
Here is a list of options and brief explanations. Visit this page for more details.
Splide provides some APIs and the way to customize the behaviour programmatically.
Splide is released under the MIT license.
© 2020 Naotoshi Fujita
FAQs
Splide is a lightweight, flexible and accessible slider/carousel. No dependencies, no Lighthouse errors.
The npm package @splidejs/splide receives a total of 160,344 weekly downloads. As such, @splidejs/splide popularity was classified as popular.
We found that @splidejs/splide 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
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.