Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 5ddd3ae

Browse files
author
Mobius1
committed
v0.5.3
1 parent 653d6e7 commit 5ddd3ae

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

dist/pageable.css

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/pageable.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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pageable",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"description": "Create full page scrolling web pages. No jQuery.",
55
"main": "dist/pageable.js",
66
"scripts": {

src/index.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SlideShow from "./classes/slideshow";
22
import Emitter from "./classes/emitter";
33

44
/**
5-
* Pageable 0.5.2
5+
* Pageable 0.5.3
66
*
77
* https://github.com/Mobius1/Pageable
88
* Released under the MIT license
@@ -195,22 +195,7 @@ export default class Pageable extends Emitter {
195195
this.lastIndex = this.pageCount - 1;
196196

197197
if (o.infinite) {
198-
const first = this.pages[0].cloneNode(true);
199-
const last = this.pages[this.lastIndex].cloneNode(true);
200-
201-
first.id = `${first.id}-clone`;
202-
last.id = `${last.id}-clone`;
203-
204-
first.classList.add("pg-clone");
205-
last.classList.add("pg-clone");
206-
207-
first.classList.remove("pg-active");
208-
last.classList.remove("pg-active");
209-
210-
this.clones = [first, last];
211-
212-
this.container.insertBefore(last, this.pages[0]);
213-
this.container.appendChild(first);
198+
this._toggleInfinite();
214199
}
215200

216201
this.bind();
@@ -226,7 +211,7 @@ export default class Pageable extends Emitter {
226211
this.emit("init", data);
227212

228213
this.initialised = true;
229-
this.container.pageable = this;
214+
this.container.pageable = this;
230215

231216
if (o.slideshow && typeof SlideShow === "function") {
232217
this.slider = new SlideShow(this);
@@ -536,9 +521,7 @@ export default class Pageable extends Emitter {
536521

537522
// remove cloned nodes
538523
if (this.config.infinite) {
539-
for (const clone of this.clones) {
540-
this.container.removeChild(clone);
541-
}
524+
this._toggleInfinite(true);
542525
}
543526

544527
// kill the slideshow
@@ -548,7 +531,7 @@ export default class Pageable extends Emitter {
548531
}
549532

550533
this.initialised = false;
551-
delete this.container.pageable;
534+
delete this.container.pageable;
552535
}
553536
}
554537

@@ -983,6 +966,34 @@ export default class Pageable extends Emitter {
983966
t
984967
);
985968
}
969+
970+
_toggleInfinite(destroy) {
971+
if ( destroy ) {
972+
for (const clone of this.clones) {
973+
this.container.removeChild(clone);
974+
}
975+
this.config.infinite = false;
976+
} else {
977+
this.config.infinite = true;
978+
979+
const first = this.pages[0].cloneNode(true);
980+
const last = this.pages[this.lastIndex].cloneNode(true);
981+
982+
first.id = `${first.id}-clone`;
983+
last.id = `${last.id}-clone`;
984+
985+
first.classList.add("pg-clone");
986+
last.classList.add("pg-clone");
987+
988+
first.classList.remove("pg-active");
989+
last.classList.remove("pg-active");
990+
991+
this.clones = [first, last];
992+
993+
this.container.insertBefore(last, this.pages[0]);
994+
this.container.appendChild(first);
995+
}
996+
}
986997

987998
/**
988999
* Limit dragging / swiping

0 commit comments

Comments
 (0)