|
37 | 37 | <script>
|
38 | 38 | import handlers from '@/mixins/handlers'
|
39 | 39 | import helpers from '@/mixins/helpers'
|
| 40 | + import preparations from '@/mixins/preparations' |
40 | 41 | import props from '@/mixins/props'
|
41 | 42 | import watchers from '@/mixins/watchers'
|
42 | 43 |
|
|
180 | 181 | this.toggleFade()
|
181 | 182 | },
|
182 | 183 |
|
183 |
| - // Prepare settings object |
184 |
| - prepareSettings () { |
185 |
| - if (!this.initialSettings.responsive) { |
186 |
| - this.toggleFade() |
187 |
| - this.toggleAutoPlay() |
188 |
| - return false |
189 |
| - } |
190 |
| -
|
191 |
| - let newSettings = Object.assign({}, this.initialSettings) |
192 |
| - delete newSettings.responsive |
193 |
| -
|
194 |
| - this.initialSettings.responsive.forEach(option => { |
195 |
| - if (this.initialSettings.mobileFirst ? option.breakpoint < this.widthWindow : option.breakpoint > this.widthWindow) { |
196 |
| - for (let key in option.settings) { |
197 |
| - newSettings[key] = option.settings[key] |
198 |
| - } |
199 |
| - } |
200 |
| - }) |
201 |
| -
|
202 |
| - this.settings = Object.assign({}, newSettings) |
203 |
| - }, |
204 |
| -
|
205 |
| - // Prepare slides classes and styles |
206 |
| - prepareSlides () { |
207 |
| - this.slides = this.htmlCollectionToArray(this.$refs.slides.children) |
208 |
| -
|
209 |
| - // Probably timeout needed |
210 |
| - if (this.clonedSlides) { |
211 |
| - this.slidesClonedBefore = this.htmlCollectionToArray(this.$refs.slidesClonedBefore.children) |
212 |
| - this.slidesClonedAfter = this.htmlCollectionToArray(this.$refs.slidesClonedAfter.children) |
213 |
| - } |
214 |
| -
|
215 |
| - for (let slide of this.allSlides) { |
216 |
| - slide.classList.add('agile__slide') |
217 |
| - } |
218 |
| - }, |
219 |
| -
|
220 |
| - // Prepare slides active/current classes |
221 |
| - prepareSlidesClasses () { |
222 |
| - // Remove active & current classes |
223 |
| - for (let i = 0; i < this.slidesCount; i++) { |
224 |
| - this.slides[i].classList.remove('agile__slide--active') |
225 |
| - this.slides[i].classList.remove('agile__slide--current') |
226 |
| - } |
227 |
| -
|
228 |
| - // Add active & current class for current slide |
229 |
| - this.slides[this.currentSlide].classList.add('agile__slide--active') |
230 |
| -
|
231 |
| - let start = (this.clonedSlides) ? this.slidesCount + this.currentSlide : this.currentSlide |
232 |
| -
|
233 |
| - if (this.centerMode) { |
234 |
| - start -= (Math.floor(this.settings.slidesToShow / 2) - +(this.settings.slidesToShow % 2 === 0)) |
235 |
| - } |
236 |
| -
|
237 |
| - // To account for the combination of infinite = false and centerMode = true, ensure we don't overrun the bounds of the slide count. |
238 |
| - for (let i = Math.max(start, 0); i < Math.min(start + this.settings.slidesToShow, this.slidesCount); i++) { |
239 |
| - this.allSlides[i].classList.add('agile__slide--current') |
240 |
| - } |
241 |
| - }, |
242 |
| -
|
243 |
| - // Prepare carousel styles |
244 |
| - prepareCarousel () { |
245 |
| - this.widthSlide = !this.settings.unagile ? this.widthContainer / this.settings.slidesToShow : 'auto' |
246 |
| -
|
247 |
| - // Actions on document resize |
248 |
| - for (let i = 0; i < this.allSlidesCount; i++) { |
249 |
| - this.allSlides[i].style.width = this.widthSlide + 'px' |
250 |
| - } |
251 |
| -
|
252 |
| - // Prepare track |
253 |
| - if (this.settings.unagile) { |
254 |
| - this.translateX = 0 |
255 |
| - } else { |
256 |
| - if (this.currentSlide === null) { |
257 |
| - this.currentSlide = this.settings.initialSlide |
258 |
| - } |
259 |
| -
|
260 |
| - this.goTo(this.currentSlide, false, false) |
261 |
| - } |
262 |
| - }, |
263 |
| -
|
264 | 184 | toggleFade () {
|
265 | 185 | let enabled = (!this.settings.unagile && this.settings.fade)
|
266 | 186 |
|
|
0 commit comments