Package Exports
- ractive-swipe-pages
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ractive-swipe-pages) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ractive-swipe-pages
Ractive component for swiping between pages. Provides a SPContainer and SPPage component for organizing things.
Installing
Currently, this only supports Browserify with npm. If anyone ever needs this outside of that, please open an issue and I'll add in your preferred module system.
npm install --save ractive-swipe-pagesExample
index.js:
var Ractive = require("ractive");
var fs = require("fs");
require("ractive-swipe-pages");
window.Ractive = Ractive;
console.log("Ractive components", Ractive.components);
var template = fs.readFileSync(__dirname + "/template.html", "utf8");
new Ractive({
el: document.querySelector("main"),
template: template
}).on("changedPage", function(data){
console.log(data);
});
template.html:
<h1>Swipe Pages Example</h1>
<SPContainer class="main-container" pages="4" page="2" on-page="changedPage">
<SPPage class="page">
Hello
</SPPage>
<SPPage class="page">
World
</SPPage>
<SPPage class="page">
This is a test of sorts
</SPPage>
<SPPage class="page">
Should be pretty easy to use
</SPPage>
</SPContainer>Usage
Just have a SPContainer wherever you want to have the pages contained, and have one or more SPPage elements as children.
Make sure to also set the pages attribute on SPContainer to set the number of pages that should be displayed.
Both SPContainer and SPPage take a class attribute to add a class to them. Try not to play with the flexbox related properties in SPContainer.
SPContainer also takes the default page to display.
Once it's set up, you now have pages that can be dragged between by users. It works with either touch inputs or a mouse.
SPContainer emits a page event whenever the page changes. The event contains one argument which is an object with the current page and the previous page.