120+ Touch-enabled Page Transitions In JavaScript - pageSwitch
| File Size: | 18.1 KB |
|---|---|
| Views Total: | 4682 |
| Last Update: | |
| Publish Date: | |
| Official Website: | Go to website |
| License: | MIT |
pageSwitch.js is a JavaScript library that provides 120+ touch-enabled, pretty awesome transition effects when switching between pages on mobile or desktop.
Also provides a jQuery adapter that makes it easier to implement these page transition effects on jQuery based web apps.
See It In Action:
More features:
- Supports mouse drag, mouse wheel and touch swipe events.
- Supports both horizontal and vertical directions.
- Also allows you to switch between pages with keyboard arrows.
- Supports up to 121 combinations of transition effects.
- Easing functions.
- Auto play.
- Cross browser and cross platform.
Transition Effects Included:
- fade
- scroll
- scroll3d
- scrollCover
- scrollCoverReverse
- scrollCoverIn
- scrollCoverOut
- scrollX
- scroll3dX
- scrollCoverX
- scrollCoverReverseX
- scrollCoverInX
- scrollCoverOutX
- scrollY
- scroll3dY
- scrollCoverY
- scrollCoverReverseY
- scrollCoverInY
- scrollCoverOutY
- slide
- slideCover
- slideCoverReverse
- slideCoverIn
- slideCoverOut
- slideX
- slideCoverX
- slideCoverReverseX
- slideCoverInX
- slideCoverOutX
- slideY
- slideCoverY
- slideCoverReverseY
- slideCoverInY
- slideCoverOutY
- flow
- flowCover
- flowCoverReverse
- flowCoverIn
- flowCoverOut
- flowX
- flowCoverX
- flowCoverReverseX
- flowCoverInX
- flowCoverOutX
- flowY
- flowCoverY
- flowCoverReverseY
- flowCoverInY
- flowCoverOutY
- slice
- sliceX
- sliceY
- zoom
- zoomCover
- zoomCoverReverse
- zoomCoverIn
- zoomCoverOut
- zoomX
- zoomCoverX
- zoomCoverReverseX
- zoomCoverInX
- zoomCoverOutX
- zoomY
- zoomCoverY
- zoomCoverReverseY
- zoomCoverInY
- zoomCoverOutY
- skew
- skewCover
- skewCoverReverse
- skewCoverIn
- skewCoverOut
- skewX
- skewCoverX
- skewCoverReverseX
- skewCoverInX
- skewCoverOutX
- skewY
- skewCoverY
- skewCoverReverseY
- skewCoverInY
- skewCoverOutY
- flip
- flip3d
- flipClock
- flipPaper
- flipCover
- flipCoverReverse
- flipCoverIn
- flipCoverOut
- flipX
- flip3dX
- flipClockX
- flipPaperX
- flipCoverX
- flipCoverReverseX
- flipCoverInX
- flipCoverOutX
- flipY
- flip3dY
- flipClockY
- flipPaperY
- flipCoverY
- flipCoverReverseY
- flipCoverInY
- flipCoverOutY
- bomb
- bombCover
- bombCoverReverse
- bombCoverIn
- bombCoverOut
- bombX
- bombCoverX
- bombCoverReverseX
- bombCoverInX
- bombCoverOutX
- bombY
- bombCoverY
- bombCoverReverseY
- bombCoverInY
- bombCoverOutY
How to use it:
1. Download the zip or install the package via NPM:
# NPM $ npm install pageswitch --save
2. Load the JavaScript file pageSwitch.js from the src folder:
<script src="src/pageSwitch.js"></script>
3. Create a group of pages to switch between.
<div id="imgs">
<div>
<img src="1.jpg" />
</div>
<div>
<img src="2.jpg" />
</div>
<div>
<img src="3.jpg" />
</div>
...
</div>
3. Attach the pageSwitch.js to the parent container and config the transition effects with the following settings.
var pw = new pageSwitch('images', {
// duration of animation
duration: 600,
// 1 = vertical, 0 = horizontal
direction: 1,
// initial page
start: 0,
// infinite loop
loop: false,
// easing function: linear ease ease-in ease-out ease-in-out bounce
ease: 'ease',
// transition effect
transition: 'slide',
// freeze the page when transitioning
freeze: false,
// enable mouse drag
mouse: true,
// enable mouse wheel
mousewheel: false,
// enable keyboard arrows
arrowkey: false,
// enable autoplay
autoplay: false,
// autoplay interval
interval: 5000
});
4. Implement the pageSwitch.js using jQuery/Zepto.
$.fn.extend({
pageSwitch: function(cfg) {
this[0].ps = new pageSwitch(this[0], cfg);
return this;
},
ps: function() {
return this[0].ps;
}
});
// init
$('#imgs').pageSwitch({
duration: 1000,
transition: 'slide'
// ...
});
// methods
$('#imgs')
.ps()
.next();
5. Available API methods to control the page transition effects with JavaScript.
pw.prev(); pw.next(); pw.slide(n); pw.setEase(); pw.setTransition(); pw.freeze(true | false); pw.play(); pw.pause(); pw.prepend(DOM_NODE); pw.append(DOM_NODE); pw.insertBefore(DOM_NODE, index); pw.insertAfter(DOM_NODE, index); pw.remove(index); pw.isStatic(); pw.destroy();
6. Event handlers.
pw.on('before', function(){
// do something
});
pw.on('after', function(){
// do something
});
pw.on('update', function(){
// do something
});
pw.on('dragStart', function(){
// do something
});
pw.on('dragMove', function(){
// do something
});
pw.on('dragEnd', function(){
// do something
});
This awesome jQuery plugin is developed by qiqiboy. For more Advanced Usages, please check the demo page or visit the official website.











