Skip to content

Commit

Permalink
Merge pull request #60 from Neovici/indexnullcheck19614
Browse files Browse the repository at this point in the history
Bugfix for updated on selected when position was on last in queue and…
  • Loading branch information
JockeCK authored Oct 8, 2018
2 parents 52f5c33 + 78726d2 commit b9c1238
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cosmoz-data-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,20 @@
* @return {void}
*/
_updateSelected(selected = this.selected, previous) {
this._setSelectedNext((selected || 0) + 1);
this._preload(selected);
const position = selected < this.items.length ? selected : selected - 1;
this._setSelectedNext((position || 0) + 1);
this._preload(position);

const element = this._getElement(selected);
const element = this._getElement(position);

this._updateHashForSelected(selected);
if (!element) {
return;
}

this._updateHashForSelected(position);

const classes = element.classList,
animating = this.animating && previous != null && previous !== selected,
animating = this.animating && previous != null && previous !== position,
prev = animating && this._getElement(previous);

if (!animating) {
Expand Down Expand Up @@ -575,7 +580,7 @@
return {
prevDisabled: index < 1,
nextDisabled: index + 1 >= this.items.length,
[this.indexAs]: Math.max(index, 0)
[this.indexAs]: Math.min(Math.max(index, 0), this.items.length - 1)
};
},

Expand Down

0 comments on commit b9c1238

Please sign in to comment.