Socket
Socket
Sign inDemoInstall

ngx-glide

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-glide

Angular wrapper component of Glide carousel library


Version published
Weekly downloads
624
increased by7.77%
Maintainers
1
Install size
212 kB
Created
Weekly downloads
 

Readme

Source

ngx-glide

Angular wrapper component of Glide carousel library.

npm NPM npm bundle size

Environment Support

  • Angular 6+
  • Server-side Rendering

Compatibility

Versions compatibility list:

ngx-glideAngular@glidejs/glide
16.x.x16.x.x3.x.x
15.x.x15.x.x3.x.x
14.x.x14.x.x3.x.x
13.x.x13.x.x3.x.x
12.x.x12.x.x3.x.x
11.x.x11.x.x3.x.x
10.x.x10.x.x3.x.x
1.x.x6.x.x - 9.x.x3.x.x

Installation

npm i @glidejs/glide@3 ngx-glide

Demo

Demo page

Usage

Add scss files to the styles section of your angular.json:

"styles": [
  "src/styles.scss",
  "node_modules/@glidejs/glide/src/assets/sass/glide.core",
  "node_modules/@glidejs/glide/src/assets/sass/glide.theme"
],

You can either import the styles files into main scss file:

@use '@glidejs/glide/src/assets/sass/glide.core' as *;
@use '@glidejs/glide/src/assets/sass/glide.theme' as *;

Import NgxGlideModule into the current module's imports:

import { NgxGlideModule } from 'ngx-glide';

imports: [
  // ...
  NgxGlideModule,
],

You can also import NgxGlideComponent as standalone component:

import { NgxGlideComponent } from 'ngx-glide';

@Component({
  standalone: true,
  imports: [NgxGlideComponent],
  // ...
})
export class MyComponent {}

Use in your components (add html items into the ngx-glide component):

<ngx-glide>
  <div>0</div>
  <div>1</div>
  <div>2</div>
</ngx-glide>

You can also access to the component instance directly like this:

// Get the component instance.
@ViewChild(NgxGlideComponent, { static: false }) ngxGlide: NgxGlideComponent;

play(): void {
  this.ngxGlide.play();
}

Update the carousel items dynamically (only available from version 12).

<ng-container *ngIf="names && names.length > 0">
  <ngx-glide #ngxGlide>
    <ng-container *ngFor="let name of names">
      <div>{{ name }}</div>
    </ng-container>
  </ngx-glide>
</ng-container>
// Get the component instance.
@ViewChild('ngxGlide') ngxGlide!: NgxGlideComponent;

names: string[];

constructor() {
  this.names = ['Johny Depp', 'Christian Bale'];
}

updateItems(): void {
  this.names = [...this.names, 'Tom Hanks'];
  if (this.ngxGlide) {
    this.ngxGlide.recreate();
  }
}

API

Inputs

InputTypeDefaultDescription
showArrowsbooleantrueIndicates if to show arrows in the view or not.
showBulletsbooleantrueIndicates if to show bullets in the view or not.
arrowLeftLabelstring'prev'The label presented in the arrow left side.
arrowLeftTemplateTemplateRefnullCustom HTML (TemplateRef) to use for arrow left this disable the default.
arrowRightLabelstring'next'The label presented in the arrow right side.
arrowRightTemplateTemplateRefnullCustom HTML (TemplateRef) to use for arrow right this disable the default.
listenToEventsbooleanfalseIf you need to get output events set it to true (by default is false to save performance).
typestring'slider'Type of the movement.
startAtnumber0Start at specific slide number.
perViewnumber1A number of visible slides.
focusAtnumber | string0Focus currently active slide at a specified position.
gapnumber10A size of the space between slide.
autoplaynumber | booleanfalseChange slides after a specified interval.
hoverpausebooleantrueStop autoplay on mouseover.
keyboardbooleantrueChange slides with keyboard arrows.
boundbooleanfalseStop running perView number of slides from the end.
swipeThresholdnumber | boolean80Minimal swipe distance needed to change the slide.
dragThresholdnumber | boolean120Minimal mousedrag distance needed to change the slide.
perTouchnumber | booleanfalseA maximum number of slides moved per single swipe or drag.
touchRationumber0.5Alternate moving distance ratio of swiping and dragging.
touchAnglenumber45Angle required to activate slides moving.
animationDurationnumber400Easing function for the animation.
rewindbooleantrueAllow looping the slider type.
rewindDurationnumber800Duration of the rewinding animation.
animationTimingFuncstring'cubic-bezier(0.165, 0.840, 0.440, 1.000)'Easing function for the animation.
directionstring'ltr'Moving direction mode.
peeknumber | object0The value of the future viewports which have to be visible in the current view.
breakpointsobject{}Collection of options applied at specified media breakpoints.
throttlenumber25Throttle costly events

Outputs

OutputEvent TypeExampleDescription
mountedBeforevoidCalled before first mounting begins. However, the mounting phase has not been started, and components are not bootstrapped yet.
mountedAftervoidCalled right after first mounting. All components have been mounted.
updatedvoidCalled right after updating settings with update() API method.
playedvoidCalled right after starting an instance with play() API method.
pausedvoidCalled right after stopping instance with pause() API method.
buildedBeforevoidCalled right before setting up a slider to its initial state. At this point, classes, translations, and sizes are applied.
buildedAftervoidCalled right after setting up a slider to its initial state. At this point, classes, translations, and sizes are applied.
ranBeforeobject{ "direction": ">", "steps": 0 }Called right before calculating new index and making a transition. The movement schema (eg. =1) string has been parsed.
ranobject{ "direction": ">", "steps": 0 }Called right after calculating new index and before making a transition. The movement schema (eg. =1) string has been parsed.
ranAfterobject{ "direction": ">", "steps": 0 }Called after calculating new index and making a transition. The movement schema (eg. =1) string has been parsed.
ranOffsetobject{ "direction": ">", "steps": 0 }Called after calculating new index and making a transition, while we did an offset animation. Offset animation take place at two moments.
runStartedobject{ "direction": ">", "steps": 0 }Called right after calculating the new index, but before making a transition, while we did a rewinding to the start index.
runEndedobject{ "direction": ">", "steps": 0 }Called right after calculating the new index, but before making a transition, while we did a rewinding to the last index.
movedobject{ "movement": 0 }Called right before movement transition begins.
movedAfterobject{ "movement": 0 }Called right after movement transition ends.
resizedvoidCalled when the window is being resized. This event throttled.
swipeStartedvoidCalled right after swiping begins.
swipeMovedvoidCalled during swiping movement.
swipeEndedvoidCalled right after swiping ends.
translateJumpedobjectCalled right before a translate applies, while we doing a jump to the first or last slide from offset movement. This event is only used when a type is set up to carousel.

License

MIT

Keywords

FAQs

Last updated on 23 Sep 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc