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

Commit

Permalink
v0.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mobius1 committed Nov 29, 2018
1 parent 5ddd3ae commit 783527a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion dist/pageable.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/pageable.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pageable",
"version": "0.5.3",
"version": "0.5.4",
"description": "Create full page scrolling web pages. No jQuery.",
"main": "dist/pageable.js",
"scripts": {
Expand Down
64 changes: 33 additions & 31 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SlideShow from "./classes/slideshow";
import Emitter from "./classes/emitter";

/**
* Pageable 0.5.3
* Pageable 0.5.4
*
* https://github.com/Mobius1/Pageable
* Released under the MIT license
Expand Down Expand Up @@ -208,7 +208,7 @@ export default class Pageable extends Emitter {
this.config.onInit.call(this, data);

// emit "init" event
this.emit("init", data);
this.emit("init", data);

this.initialised = true;
this.container.pageable = this;
Expand Down Expand Up @@ -531,7 +531,7 @@ export default class Pageable extends Emitter {
}

this.initialised = false;
delete this.container.pageable;
delete this.container.pageable;
}
}

Expand Down Expand Up @@ -966,34 +966,36 @@ export default class Pageable extends Emitter {
t
);
}

_toggleInfinite(destroy) {
if ( destroy ) {
for (const clone of this.clones) {
this.container.removeChild(clone);
}
this.config.infinite = false;
} else {
this.config.infinite = true;

const first = this.pages[0].cloneNode(true);
const last = this.pages[this.lastIndex].cloneNode(true);

first.id = `${first.id}-clone`;
last.id = `${last.id}-clone`;

first.classList.add("pg-clone");
last.classList.add("pg-clone");

first.classList.remove("pg-active");
last.classList.remove("pg-active");

this.clones = [first, last];

this.container.insertBefore(last, this.pages[0]);
this.container.appendChild(first);
}
}

_toggleInfinite(destroy) {
if (destroy && this.config.infinite) {
for (const clone of this.clones) {
this.container.removeChild(clone);
}
this.config.infinite = false;
} else if (!this.config.infinite) {
this.config.infinite = true;

const first = this.pages[0].cloneNode(true);
const last = this.pages[this.lastIndex].cloneNode(true);

first.id = `${first.id}-clone`;
last.id = `${last.id}-clone`;

first.classList.add("pg-clone");
last.classList.add("pg-clone");

first.classList.remove("pg-active");
last.classList.remove("pg-active");

this.clones = [first, last];

this.container.insertBefore(last, this.pages[0]);
this.container.appendChild(first);
}

this.update();
}

/**
* Limit dragging / swiping
Expand Down

0 comments on commit 783527a

Please sign in to comment.