Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@bartholomej/ngx-splide
Advanced tools
Splide.js integration to angular
https://justcommunication-ru.github.io/ngx-splide/
Using npm
npm i --save ngx-splide
Or if you prefer yarn
yarn add ngx-splide
Add splide.js into your build scripts in angular.json
:
"scripts": [
"node_modules/@splidejs/splide/dist/js/splide.js",
]
And styles if you need it:
"styles": [
"node_modules/@splidejs/splide/dist/css/splide.min.css",
"node_modules/@splidejs/splide/dist/css/themes/splide-default.min.css"
]
Add NgxSplideModule
into app.module.ts
import { NgxSplideModule } from 'ngx-splide';
@NgModule({
//...
imports: [
//...
NgxSplideModule
],
//...
})
export class AppModule {}
You can use <splide />
root component with <splide-slide />
components inside.
<splide>
<splide-slide>
<img src="image1.jpg" alt="" />
</splide-slide>
<splide-slide>
<img src="image2.jpg" alt="" />
</splide-slide>
</splide>
<splide [options]="{ type: 'loop', perPage: 1, keyboard: false }">
<splide-slide *ngFor="let image of images">
<img [src]="image.src" alt="" />
</splide-slide>
</splide>
Please refer to official documentation for the list of supported options https://splidejs.com/options/
<splide (onInit)="onSplideInit($event)">
<splide-slide>
<img src="image1.jpg" alt="" />
</splide-slide>
<splide-slide>
<img src="image2.jpg" alt="" />
</splide-slide>
</splide>
onSplideInit(splide)
{
console.log(splide);
}
You can programatically change selected splide slide with selectedSlideIndex
option
<button type="button"
*ngFor="let image of images; let index = index"
(click)="selectedImageIndex = index">Select image {{ index + 1 }}</button>
<splide [options]="{ type: 'loop', perPage: 1, keyboard: false }">
<splide-slide *ngFor="image in images" [selectedSlideIndex]="selectedImageIndex">
<img [src]="image.src" alt="" />
</splide-slide>
</splide>
Events can be handled in two ways:
<splide
(onInit)="onSplideInit($event)"
(onMounted)="onSplideMounted($event)"
(onUpdated)="onSplideUpdated($event)"
(onMove)="onSplideMove($event)"
(onMoved)="onSplideMoved($event)"
(onDrag)="onSplideDrag($event)"
(onDragged)="onSplideDragged($event)"
(onVisible)="onSplideVisible($event)"
(onHidden)="onSplideHidden($event)"
(onActive)="onSplideActive($event)"
(onInactive)="onSplideInactive($event)"
(onClick)="onSplideClick($event)"
(onArrowsMounted)="onSplideArrowsMounted($event)"
(onArrowsUpdated)="onSplideArrowsUpdated($event)"
(onPaginationMounted)="onSplidePaginationMounted($event)"
(onPaginationUpdated)="onSplidePaginationUpdated($event)"
(onNavigationMounted)="onSplideNavigationMounted($event)"
(onAutoplayPlay)="onSplideAutoplayPlay($event)"
(onAutoplayPause)="onSplideAutoplayPause($event)"
(onAutoplayPlaying)="onSplideAutoplayPlaying($event)"
(onLazyloadLoaded)="onSplideLazyloadLoaded($event)"
>
onSplideMoved(args)
{
const newIndex = args[0];
const oldIndex = args[1];
const destIndex = args[2];
}
<splide (onSplideEvent)="onSplideEvent($event)">
Event object:
{
"name": <event-name>,
"args": <event-arguments>
}
event-name
– name of the splide event listed in https://splidejs.com/events/
event-arguments
– array of arguments.
For example moved
event will be:
{
"name": "moved",
"args": [ 1, 0, 1 ] // newIndex, oldIndex, destIndex
}
onSplideEvent(event)
{
console.log('Splide event', event.name, 'with arguments', event.args);
switch (event.name) {
case 'moved':
const newIndex = event.args[0];
const oldIndex = event.args[1];
const destIndex = event.args[2];
break;
}
}
You can sync splide instances like it described in https://splidejs.com/guides/apis/#sync
Just create @ViewChild
in your controller:
@ViewChild('mainSplide') mainSplide: NgxSplideComponent;
@ViewChild('secondarySplide') secondarySplide: NgxSplideComponent;
And pass instances with [syncWith]
:
<splide #mainSplide [syncWith]="secondarySplide">...</splide>
<splide #secondarySplide [syncWith]="mainSplide">...</splide>
You can also pass containerClass
to append custom class for root div.splide
node
<splide containerClass="customSplideClass">
Will produce:
<div class="splide customSplideClass">
...
</div>
FAQs
Splide.js integration with angular
The npm package @bartholomej/ngx-splide receives a total of 2 weekly downloads. As such, @bartholomej/ngx-splide popularity was classified as not popular.
We found that @bartholomej/ngx-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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.