Skip to content

Commit 8b6c4df

Browse files
cedric07cursoragent
andcommitted
fix(Slider): forward Swiper this in afterInit and transitionEnd
Consumer on handlers expect the Swiper instance as `this`; use function handlers and .call like progress/slideChange. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 185e670 commit 8b6c4df

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/js/classes/Slider.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default class Slider extends AbstractDomElement {
124124
},
125125
on: {
126126
...options.on,
127-
afterInit: (swiper) => {
127+
afterInit: function (swiper) {
128128
hideNavigationButtons(swiper)
129129

130130
// Live region announces nav messages on keyboard prev/next; keep it when
@@ -133,12 +133,12 @@ export default class Slider extends AbstractDomElement {
133133
swiper.el.querySelector('.swiper-notification')?.remove()
134134
}
135135

136-
options.on?.afterInit?.(swiper)
136+
options.on?.afterInit?.call(this, swiper)
137137
},
138138
// Swiper resets tabindex on slide change, so we need to hide buttons again
139-
transitionEnd: (swiper) => {
139+
transitionEnd: function (swiper) {
140140
hideNavigationButtons(swiper)
141-
options.on?.transitionEnd?.(swiper)
141+
options.on?.transitionEnd?.call(this, swiper)
142142
},
143143
progress: function (swiper, progress) {
144144
if (fixLastSlideActiveOnEnd) {

0 commit comments

Comments
 (0)