Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions resources/js/components/Elements/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default {
scroll(event) {
this.position = this.vertical ? event.target.scrollTop : event.target.scrollLeft
this.showLeft = this.loop || this.position
this.showRight = this.loop || this.container.offsetWidth + this.position < this.container.scrollWidth - 1
this.showRight = this.loop || this.container?.offsetWidth + this.position < this.container?.scrollWidth - 1
},
scrollend(event) {
let scrollPosition = this.vertical ? event.target.scrollTop : event.target.scrollLeft
Expand Down Expand Up @@ -154,8 +154,8 @@ export default {
index = this.loop ? index + this.slides.length : index

this.vertical
? this.slider.scrollTo({ top: this.container.children[index]?.offsetTop, behavior: behavior })
: this.slider.scrollTo({ left: this.container.children[index]?.offsetLeft, behavior: behavior })
? this.slider.scrollTo({ top: this.container?.children[index]?.offsetTop, behavior: behavior })
: this.slider.scrollTo({ left: this.container?.children[index]?.offsetLeft, behavior: behavior })
},
handleLoop() {
requestAnimationFrame(() => {
Expand All @@ -176,12 +176,12 @@ export default {
let slide = this.childSpan == 0 ? 0 : this.currentSlide

this.childSpan = this.vertical
? (this.container.children[0]?.offsetHeight ?? this.container.offsetHeight)
: (this.container.children[0]?.offsetWidth ?? this.container.offsetWidth)
? (this.container?.children[0]?.offsetHeight ?? this.container?.offsetHeight)
: (this.container?.children[0]?.offsetWidth ?? this.container?.offsetWidth)

this.navigate(slide, 'instant')

this.sliderSpan = this.vertical ? this.container.offsetHeight : this.container.offsetWidth
this.sliderSpan = this.vertical ? this.container?.offsetHeight : this.container?.offsetWidth
})
},
},
Expand Down Expand Up @@ -219,6 +219,9 @@ export default {
return (this.slides?.length ?? 1) - (this.loop ? 0 : this.slidesVisible - 1)
},
slides() {
if (!this.mounted || !this.container) {
return []
}
return this.container.querySelectorAll(':scope > :not([data-clone=true])')
},
sliderStart() {
Expand Down
Loading