Skip to content

Commit 57776e9

Browse files
Bug Fix: The number of images that lazy load images is one more than intended.
Bug Fix: When the slider is looping and an image is just loaded simultaneously, the position unexpectedly jumps to the `index` that should be `dest`.
1 parent bd02cbd commit 57776e9

File tree

16 files changed

+76
-34
lines changed

16 files changed

+76
-34
lines changed

dist/js/splide-renderer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.cjs.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Splide.js
3-
* Version : 3.2.0
3+
* Version : 3.2.1
44
* License : MIT
55
* Copyright: 2021 Naotoshi Fujita
66
*/
@@ -869,7 +869,7 @@ function Slide$1(Splide2, index, slideIndex, slide) {
869869
}
870870
function isWithin(from, distance) {
871871
let diff = abs(from - index);
872-
if (!Splide2.is(SLIDE) && !isClone) {
872+
if (!isClone && (options.rewind || Splide2.is(LOOP))) {
873873
diff = min(diff, Splide2.length - diff);
874874
}
875875
return diff <= distance;
@@ -1173,7 +1173,7 @@ function Move(Splide2, Components2, options) {
11731173
removeAttribute(list, "style");
11741174
}
11751175
function reposition() {
1176-
if (!Components2.Drag.isDragging()) {
1176+
if (!isBusy() && !Components2.Drag.isDragging()) {
11771177
Components2.Scroll.cancel();
11781178
jump(Splide2.index);
11791179
emit(EVENT_REPOSITIONED);
@@ -1958,7 +1958,7 @@ function LazyLoad(Splide2, Components2, options) {
19581958
const _spinner = create("span", options.classes.spinner, _img.parentElement);
19591959
setAttribute(_spinner, ROLE, "presentation");
19601960
images.push({ _img, _Slide, src, srcset, _spinner });
1961-
display(_img, "none");
1961+
!_img.src && display(_img, "none");
19621962
}
19631963
});
19641964
});
@@ -1972,7 +1972,8 @@ function LazyLoad(Splide2, Components2, options) {
19721972
}
19731973
function observe() {
19741974
images = images.filter((data) => {
1975-
if (data._Slide.isWithin(Splide2.index, options.perPage * ((options.preloadPages || 1) + 1))) {
1975+
const distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
1976+
if (data._Slide.isWithin(Splide2.index, distance)) {
19761977
return load(data);
19771978
}
19781979
return true;

dist/js/splide.esm.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Splide.js
3-
* Version : 3.2.0
3+
* Version : 3.2.1
44
* License : MIT
55
* Copyright: 2021 Naotoshi Fujita
66
*/
@@ -865,7 +865,7 @@ function Slide$1(Splide2, index, slideIndex, slide) {
865865
}
866866
function isWithin(from, distance) {
867867
let diff = abs(from - index);
868-
if (!Splide2.is(SLIDE) && !isClone) {
868+
if (!isClone && (options.rewind || Splide2.is(LOOP))) {
869869
diff = min(diff, Splide2.length - diff);
870870
}
871871
return diff <= distance;
@@ -1169,7 +1169,7 @@ function Move(Splide2, Components2, options) {
11691169
removeAttribute(list, "style");
11701170
}
11711171
function reposition() {
1172-
if (!Components2.Drag.isDragging()) {
1172+
if (!isBusy() && !Components2.Drag.isDragging()) {
11731173
Components2.Scroll.cancel();
11741174
jump(Splide2.index);
11751175
emit(EVENT_REPOSITIONED);
@@ -1954,7 +1954,7 @@ function LazyLoad(Splide2, Components2, options) {
19541954
const _spinner = create("span", options.classes.spinner, _img.parentElement);
19551955
setAttribute(_spinner, ROLE, "presentation");
19561956
images.push({ _img, _Slide, src, srcset, _spinner });
1957-
display(_img, "none");
1957+
!_img.src && display(_img, "none");
19581958
}
19591959
});
19601960
});
@@ -1968,7 +1968,8 @@ function LazyLoad(Splide2, Components2, options) {
19681968
}
19691969
function observe() {
19701970
images = images.filter((data) => {
1971-
if (data._Slide.isWithin(Splide2.index, options.perPage * ((options.preloadPages || 1) + 1))) {
1971+
const distance = options.perPage * ((options.preloadPages || 1) + 1) - 1;
1972+
if (data._Slide.isWithin(Splide2.index, distance)) {
19721973
return load(data);
19731974
}
19741975
return true;

dist/js/splide.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/splide.min.js.gz

20 Bytes
Binary file not shown.

dist/types/components/LazyLoad/LazyLoad.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splidejs/splide",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"description": "Splide is a lightweight, flexible and accessible slider/carousel. No dependencies, no Lighthouse errors.",
55
"author": "Naotoshi Fujita",
66
"license": "MIT",
@@ -64,7 +64,8 @@
6464
"check:types": "tsc --noEmit",
6565
"jest": "jest --clearCache && jest",
6666
"eslint": "eslint src",
67-
"stylelint": "npx stylelint --fix ./src/css/**/*.scss"
67+
"stylelint": "npx stylelint --fix ./src/css/**/*.scss",
68+
"beforecommit": "npm run eslint && npm run stylelint && npm run jest && npm run build:all"
6869
},
6970
"browserslist": [
7071
"> 5%",

0 commit comments

Comments
 (0)