vitalii-andriiovskyi / ngx-owl-carousel-o

owl-carousel for Angular >=6
MIT License
177 stars 51 forks source link

Wrong center being returned in events #80

Open nofalx opened 4 years ago

nofalx commented 4 years ago

Hi, thank you for this library.

I was using the events callback and it seems to be reporting the wrong center. The example case is as following:

if we console.log the event from carouselChanged you will notice that the center and start index are correct, after first scroll you will get the same output, then if you scroll again the index will start moving but lagging 1 position behind

angular version ngx-owl: "^3.0.0"

Thank you

vitalii-andriiovskyi commented 4 years ago

Hi @nofalx .

It seems everything is ok. I changed ids in slidesStore:

slidesStore = [
    {
        id: 'slide-0',
    },
    {
        id: 'slide-1',
    },
    {
        id: 'slide-2',
    },
    {
        id: 'slide-3',
    },
    {
        id: 'slide-4',
    },
    {
        id: 'slide-5',
    },
    {
        id: 'slide-6',
    },
    {
        id: 'slide-7',
    },
]

id: 'slide-0' is the id for the first slide that is in the array on position 0. The option startPosition always shows the index of the slide in the slidesStore. That is when I finished dragging and the slide with id slide-3 is in the center, startPosition = 3 . Yea this slide is 4th slide, but it's on index 3 in the array.

And I see the same thing is with your example. Of course, if I understood your explanation correctly.