Skip to content

Commit

Permalink
Fixed a bug where the wrong dot in the dotNavigation was activated wh…
Browse files Browse the repository at this point in the history
…en the slideAmount was not perfectly dividible by the slidesPerPage.
  • Loading branch information
LukasMeier committed Aug 29, 2019
1 parent b751cd8 commit b1f234b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/lumens.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion js/lumens.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ export default class Lumens {
if (this.dotNavigation) {
this.dotnav = document.createElement("div")
this.dotnav.className = "lumens__dot-nav"
this.dotnav.style.margin = "0 auto"

if (!this.dotnavStyling.ownStyle) {
this.dotnav.style.margin = "0 auto"
this.dotnav.style.textAlign = "center"
}

this.dotamount = this.infinite ? Math.ceil((this.slideAmount - this.slidesPerPage * 2) / this.slidesPerPage) : Math.ceil(this.slideAmount / this.slidesPerPage)
this.track.after(this.dotnav)
for (let i = 0; i < this.dotamount; i++) {
Expand Down Expand Up @@ -107,6 +112,9 @@ export default class Lumens {
if (this.dotNavigation) {
let dotIndex = this.infinite ? Math.floor(this.currentPage / this.slidesPerPage) - 1 : Math.floor(this.currentPage / this.slidesPerPage)
this.dotnav.querySelectorAll("." + this.dotnavStyling.className).forEach((tmp, index) => {
if (this.currentPage + this.slidesPerPage == this.slideAmount && !Number.isInteger(this.currentPage / this.slidesPerPage)) {
index--
}
tmp.className = index === dotIndex ? this.dotnavStyling.className + " " + this.dotnavStyling.className + "--active" : this.dotnavStyling.className
})

Expand Down

0 comments on commit b1f234b

Please sign in to comment.