I'm submitting a ...
What is the current behavior?
I've noticed that the indexChanged method is not working properly for some reason. Sometimes it is returning the last index, but when I look at the carousel it is not at the end. I suppose because of that the method moveRight isn't working any more (last index reached).
You should be able to reproduce it by invoking method indexChanged and compare it with actual index (visually).
What is the expected behavior?
I expect to get the correct index, but for some reason at any point of usage the index is jumping to the last one.
What is the motivation / use case for changing the behavior?
By debugging this, method MoveRight/MoveLeft could be used again.
Please tell us about your environment:
Hi @Andi1990 , are you able to reproduce the issue with the demo application carousel? I can't seem to reproduce the just to last index issue.
The link to the demo is dead. Do you have another, maybe fiddle or so?
However, the reason might be that I have div's instead of img's which are in the drag-scroll container
You can run the demo with
$ git clone [email protected]:bfwg/ngx-drag-scroll.git
$ cd ngx-drag-scroll
$ npm install
$ npm start
I ran the demo by cloning https://github.com/bfwg/ngx-drag-scroll.git and it worked, thank you.
I could reproduce the issue:
The following console output is produced by just clicking the move-right-button several times:
Angular is running in the development mode. Call enableProdMode() to enable the production mode.
ngx-drag-scroll.ts:113 index changed to 1
ngx-drag-scroll.ts:113 index changed to 0
ngx-drag-scroll.ts:113 index changed to 1
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 2
ngx-drag-scroll.ts:113 index changed to 1
ngx-drag-scroll.ts:113 index changed to 2
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 3
ngx-drag-scroll.ts:113 index changed to 2
ngx-drag-scroll.ts:113 index changed to 3
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 4
ngx-drag-scroll.ts:113 index changed to 3
ngx-drag-scroll.ts:113 index changed to 4
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 5
ngx-drag-scroll.ts:113 index changed to 4
ngx-drag-scroll.ts:113 index changed to 5
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 6
ngx-drag-scroll.ts:113 index changed to 5
ngx-drag-scroll.ts:113 index changed to 6
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 7
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 8
ngx-drag-scroll.ts:113 index changed to 9
home.component.ts:92 snap animation finished
ngx-drag-scroll.ts:113 index changed to 8
ngx-drag-scroll.ts:113 index changed to 9
home.component.ts:92 snap animation finished
in ngx-drag-scroll.ts I have just added one line for my console output:
set currIndex(value) {
if (value !== this._index) {
this._index = value;
this.indexChanged.emit(value);
console.log('index changed to ' + this._index);
}
}
So there are two problems:
Please give 2.0.0-beta.7 a try. Let me know if I need to reopen this. Thanks for reporting!
Unfortunately the issue still exists..please reopen it.
I tried the demo with [email protected] and it turns out that from index 6 up to index 10, the movement is not working. I would expect that the images still move to the left, when I press the button "right".
It turns out that the issue only occurs when the last image (index) is selected. Navigating then to the previous image (by scrolling or button), the navigation works fine but the function _indexChanged()_ doesn't recognize the changed index or rather it wrongly toggles to the last index again.
Example console output when trying to move from last image to the previous one (last index = 8):
index changed 7
index changed 8
Any help?
I'll take a look today after work. Sorry for the delay.
Hi @Andi1990 , can you give 2.0.2 a try? Thanks
It works, nice job!
Most helpful comment
Unfortunately the issue still exists..please reopen it.
I tried the demo with [email protected] and it turns out that from index 6 up to index 10, the movement is not working. I would expect that the images still move to the left, when I press the button "right".