Skip to content

Commit

Permalink
fix(lazy): fixed issue with lazy loading when freeMode stops without …
Browse files Browse the repository at this point in the history
…momentum

fixes #4274
fixes #4275
  • Loading branch information
nolimits4web committed Mar 2, 2021
1 parent 51fd048 commit 82bcc5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/components/core/events/onTouchEnd.js
Expand Up @@ -231,6 +231,7 @@ export default function onTouchEnd(event) {
});
}
} else {
swiper.emit('_freeModeNoMomentumRelease');
swiper.updateProgress(newPosition);
}

Expand All @@ -239,6 +240,8 @@ export default function onTouchEnd(event) {
} else if (params.freeModeSticky) {
swiper.slideToClosest();
return;
} else if (params.freeMode) {
swiper.emit('_freeModeNoMomentumRelease');
}

if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) {
Expand Down
7 changes: 1 addition & 6 deletions src/components/lazy/lazy.js
Expand Up @@ -257,12 +257,7 @@ export default {
swiper.lazy.load();
}
},
resize(swiper) {
if (swiper.params.lazy.enabled) {
swiper.lazy.load();
}
},
scrollbarDragMove(swiper) {
'scrollbarDragMove resize _freeModeNoMomentumRelease': function lazyLoad(swiper) {
if (swiper.params.lazy.enabled) {
swiper.lazy.load();
}
Expand Down
14 changes: 11 additions & 3 deletions src/types/swiper-events.d.ts
Expand Up @@ -215,27 +215,35 @@ export interface SwiperEvents {
* !INTERNAL: Event will fired right before breakpoint change
*/
_beforeBreakpoint?: (swiper: Swiper, breakpointParams: SwiperOptions) => void;

/**
* !INTERNAL: Event will fired after setting CSS classes on swiper container element
*/
_containerClasses?: (swiper: Swiper, classNames: string) => void;

/**
* INTERNAL: Event will fired after setting CSS classes on swiper slide element
* !INTERNAL: Event will fired after setting CSS classes on swiper slide element
*/
_slideClass?: (swiper: Swiper, el: HTMLElement, classNames: string) => void;

/**
* INTERNAL: Event will fired after setting CSS classes on all swiper slides
* !INTERNAL: Event will fired after setting CSS classes on all swiper slides
*/
_slideClasses?: (
swiper: Swiper,
slides: { el: HTMLElement; classNames: string; index: number }[],
) => void;

/**
* INTERNAL: Event will fired as soon as swiper instance available (before init)
* !INTERNAL: Event will fired as soon as swiper instance available (before init)
*/
_swiper?: (swiper: Swiper) => void;

/**
* !INTERNAL: Event will be fired on free mode touch end (release) and there will no be momentum
*/
_freeModeNoMomentumRelease?: (swiper: Swiper) => void;

/**
* Event will fired on active index change
*/
Expand Down

0 comments on commit 82bcc5c

Please sign in to comment.