Ngx-drag-scroll: method indexChanged / moveRight doesn't work

Created on 17 Sep 2018  ·  10Comments  ·  Source: bfwg/ngx-drag-scroll

  • I'm submitting a ...

    • [x] bug report
    • [ ] feature request
    • [ ] support request => Please do not submit support request here, see note at the top of this template.
  • 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).

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem you can use the demo site as an example or via https://plnkr.co

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:

    • Browser: Chrome
bug

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".

All 10 comments

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:

  • Why is it toggling the index?
  • And for some reason when clicking the button several times it jumps to index 9 and the button isn't working any more (no movement).

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IlCallo picture IlCallo  ·  14Comments

suresh2018 picture suresh2018  ·  22Comments

Andi1990 picture Andi1990  ·  7Comments

Sprauch picture Sprauch  ·  13Comments

tommykamkcm picture tommykamkcm  ·  17Comments