diff --git a/src/js/thumbnails.js b/src/js/thumbnails.js index 204e99c..42882ed 100644 --- a/src/js/thumbnails.js +++ b/src/js/thumbnails.js @@ -1,15 +1,16 @@ class Thumbnails { constructor (options) { this.container = options.container; - this.barWrap = options.barWrap; + this.barWidth = options.barWidth; this.container.style.backgroundImage = `url('${options.url}')`; this.events = options.events; } - resize (width, height) { + resize (width, height, barWrapWidth) { this.container.style.width = `${width}px`; this.container.style.height = `${height}px`; this.container.style.top = `${-height + 2}px`; + this.barWidth = barWrapWidth; } show () { @@ -18,8 +19,8 @@ class Thumbnails { } move (position) { - this.container.style.backgroundPosition = `-${(Math.ceil(position / this.barWrap.offsetWidth * 100) - 1) * 160}px 0`; - this.container.style.left = `${Math.min(Math.max(position - this.container.offsetWidth / 2, -10), this.barWrap.offsetWidth - 150)}px`; + this.container.style.backgroundPosition = `-${(Math.ceil(position / this.barWidth * 100) - 1) * 160}px 0`; + this.container.style.left = `${Math.min(Math.max(position - this.container.offsetWidth / 2, -10), this.barWidth - 150)}px`; } hide () {