mujtaba01 / ngx-owl-carousel

An angular2 (4) wrapper for jquery owl-carousel library with dynamic carousel item change detection
MIT License
70 stars 25 forks source link

how to attach event/callback? #55

Open Mukeysh opened 6 years ago

Mukeysh commented 6 years ago

I just want to know how to attach an event with the carousel. E.g: I want to attach onDragged callback with the carousel. Any help would be appreciated.

dgbarbosa commented 6 years ago

@Mukeysh any news? I'm having the same question here

Mukeysh commented 6 years ago

@dgbarbosa I have done this following: .html <owl-carousel [options]='{items: 1, dots: false, navigation: false, stagePadding: 30, margin:10, onDrag: this.owlDrag.bind(this)}' [items]="images" [carouselClasses]="['owl-theme', 'owl-package','sliding']"> <div class="item" *ngFor="let slide of slides">

{{slide.text}}

 </div>
</owl-carousel>

.ts file owlDrag(event) {

}

rkpip3 commented 3 years ago

add this in options:

    mouseDrag: true,
    touchDrag: true,
    pullDrag: true,

add "(dragging)="startDragging($event.dragging)" <owl-carousel-o [options]="customOptions" #owlElement (dragging)="startDragging($event.dragging)">

  startDragging(event){
    console.log(event);
  }