• Stars
    star
    189
  • Rank 197,494 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Universal (a.k.a isomorphic) version of Swipe.js

Universal (a.k.a isomorphic) Swipe.js

npm version Download Count Buy Me A Coffee

Fork of original Swipe in order to be published to NPM (has no deps) and being compatible with universal apps.

Install

npm install swipe-js-iso --save

โœ… PRO HINT: Use ReactSwipe component

Usage

Swipe only needs to follow a simple layout pattern. Here is an example:

<div id="slider" class="swipe">
  <div class="swipe-wrap">
    <div></div>
    <div></div>
    <div></div>
  </div>
</div>

Above is the initial required structure โ€“ a series of elements wrapped in two containers. Place any content you want within the items. The containing div will need to be passed to the Swipe function like so:

const mySwipe = Swipe(document.getElementById('slider'));

I always place this at the bottom of the page, externally, to verify the page is ready.

Also Swipe needs just a few styles added to your stylesheet:

.swipe {
  overflow: hidden;
  visibility: hidden;
  position: relative;
}
.swipe-wrap {
  overflow: hidden;
  position: relative;
}
.swipe-wrap > div {
  float: left;
  width: 100%;
  position: relative;
}

Config Options

Swipe can take an optional second parameterโ€“ an object of key/value settings:

  • startSlide Integer (default:0) - index position Swipe should start at

  • speed Integer (default:300) - speed of prev and next transitions in milliseconds.

  • widthOfSiblingSlidePreview Integer - Width of next and previous slide preview in pixels

  • auto Integer - begin with auto slideshow (time in milliseconds between slides)

  • continuous Boolean (default:true) - create an infinite feel with no endpoints

  • disableScroll Boolean (default:false) - stop any touches on this container from scrolling the page

  • stopPropagation Boolean (default:false) - stop event propagation

  • swiping Function - invoked while swiping with the percentage (0-1) of the full width that has been swiped.

  • callback Function - runs at slide change.

  • transitionEnd Function - runs at the end slide transition.

Example

const mySwipe = new Swipe(document.getElementById('slider'), {
  startSlide: 2,
  speed: 400,
  widthOfSiblingSlidePreview: 10,
  auto: 3000,
  continuous: true,
  disableScroll: false,
  stopPropagation: false,
  callback: function(index, elem) {},
  transitionEnd: function(index, elem) {}
});

Swipe API

Swipe exposes a few functions that can be useful for script control of your slider.

prev() slide to prev

next() slide to next

getPos() returns current slide index position

getNumSlides() returns the total amount of slides

slide(index, duration) slide to set index position (duration: speed of transition in milliseconds)

disableScrolling(disableScroll) directly control scrolling (disableScroll: same as the config option )

Browser Support

Swipe is now compatible with all browsers, including IE7+. Swipe works best on devices that support CSS transforms and touch, but can be used without these as well. A few helper methods determine touch and CSS transition support and choose the proper animation methods accordingly.

Who's using Swipe


MIT License

More Repositories

1

flux-comparison

๐Ÿ“ Practical comparison of different Flux solutions
JavaScript
2,785
star
2

oceanic-next-color-scheme

๐Ÿ“ Sublime Text color scheme ready for next generation JavaScript syntax
JavaScript
1,972
star
3

jquery.avgrund.js

Avgrund is jQuery plugin with new modal concept for popups
JavaScript
1,764
star
4

react-swipe

โ†”๏ธ Swipe.js as a React component
JavaScript
1,662
star
5

ngActivityIndicator

Angular provider for preloader animations
CSS
644
star
6

esnextbin

๐Ÿฑ Prototype apps in the browser with next generation JavaScript and NPM modules
JavaScript
463
star
7

ngprogress-lite

Angular provider for slim progress bars
HTML
394
star
8

react-native-effects-view

Use iOS8 UIVisualEffectViews's blur and vibrancy with ReactNative
Objective-C
387
star
9

react-star-rating-component

Basic React component for star (or any other icon based) rating elements
JavaScript
378
star
10

realtime-geolocation-demo

Realtime geolocation with HTML5 API and Socket.io
JavaScript
337
star
11

melchior.js

Chainable Module Definition (CMD) dependency loader for JavaScript
JavaScript
305
star
12

soundcloud-audio.js

๐ŸŽต SoundCloud tracks and playlists with HTML5 Audio API
JavaScript
285
star
13

universal-react-flux-boilerplate

React (0.13.x) + Flux (Flummox) + ReactRouter (0.13.x) + Server Rendering
JavaScript
170
star
14

simon-le-bottle

Getting started with Facebook Messaging Platform
JavaScript
111
star
15

dookie-css

stylus driven css library
CSS
109
star
16

node-tweet-cli

Start making tweets from your bash, zsh, whatever!
JavaScript
83
star
17

xml2obj-stream

XML to JavaScript object low memory streaming parser based on node-expat
JavaScript
63
star
18

griddy.css

๐Ÿ“– Responsive 12 column based grid in 311 Bytes gzipped
HTML
63
star
19

ngKookies

Powerful replacer for built-in Angular's $cookieStore (https://github.com/angular/angular.js/issues/950)
JavaScript
60
star
20

is-express-schema-valid

๐Ÿ express.js middleware that validates body, params, query of request according to JSONSchema and is extremely fast
JavaScript
59
star
21

node-object-encrypter

Encrypt/decrypt javascript objects as base64 strings with optional TTL support
JavaScript
58
star
22

express-api-sample

Sample API ready to be used in different client app boilerplates and playgrounds.
JavaScript
48
star
23

babel-transform-in-browser

Transform ES2015 in browser on the fly with Babel.js
JavaScript
45
star
24

node-tiny-dploy

Simple shell script + PM2 deployer
JavaScript
42
star
25

dumbugger

Automatically google for similar JavaScript errors when thrown.
HTML
38
star
26

node-grvtr

grvtr.js - small node.js gravatar library
JavaScript
32
star
27

node-config-boilerplate

Easy configs for node.js apps
JavaScript
28
star
28

react-pikaday-component

Universal React component wrapper around Pikaday.js datepicker
JavaScript
19
star
29

psi-local-cli

Google PageSpeed Insights CLI for localhost (via ngrok)
JavaScript
18
star
30

data-structures-and-algorithms-in-javascript

Basic data structures and algorithms implemented in JavaScript
JavaScript
16
star
31

Do-I-Know-JS

Javascript patterns uncovered with examples
JavaScript
13
star
32

setup-osx-work-station

๐ŸŽ OS X machine setup shell script
Shell
11
star
33

is-my-schema-valid

Simple function that validates data according to JSONSchema
JavaScript
9
star
34

versionify-assets

Function to get checksum of file and add to url querystring for cache busting
JavaScript
7
star
35

vapor-favicon-middleware

Favicon serving middleware for Vapor applications.
Swift
6
star
36

react-router-hooks-patch

Patch react-router route handler components with static hook methods onEnter/onLeave
JavaScript
6
star
37

uneasy-flux-demo

Practical flux to manage uneasy API scenarios like handling errors or pending requests
JavaScript
5
star
38

create-static

Create static html pages with esnext, scss and nunjucks easily.
JavaScript
5
star
39

c0nfig

Require local configs as if they are in node_modules
JavaScript
5
star
40

EightTracksSwift

8tracks radio client for iOS8 implemented in Swift
Swift
5
star
41

EightTracksReactNative

8tracks radio client for iOS powered by ReactNative
JavaScript
4
star
42

update-to-latest

Simple cli tool for easy update of npm dependencies.
JavaScript
3
star
43

waveform.js

Waveform.js makes drawing SoundCloud waveforms simple
JavaScript
3
star
44

node-shufflerfm

Shuffler.fm API client for Node.js
JavaScript
3
star
45

discogs-wantlist-cli

๐Ÿ“€ Extract releases from Discogs user wantlist without duplicates.
JavaScript
2
star
46

vapor-server-example

Examples of server-side Swift powered by Vapor.
Swift
2
star
47

go2url.xyz

๐ŸŒ Change window.location in a second
HTML
2
star
48

swapi-graphql-react-app

SPA that allows to ๐Ÿ”Ž search for all human characters in ๐ŸŒ  Star Wars saga.
JavaScript
2
star
49

react-waves

Top sounds of the web built with React components
JavaScript
2
star
50

isomorphic-flux-comparison

2
star
51

react-ace-preact-compat-issue

JavaScript
2
star
52

vapor-checksum-assets

Add checksums of .js/.css files to url querystring in Vapor applications for cache busting.
Swift
2
star
53

telepath-mini

Tiny and smart music player for OS X
CSS
2
star
54

melchior-landing

CSS
2
star
55

multi-translator

Get transations from several dictionaries in one app.
JavaScript
2
star
56

luvit-static-server-demo

Static server demo based on luvit.io
Lua
2
star
57

next-13-ninetailed-middleware-issue

TypeScript
1
star
58

soundcloud-api-proxy

๐ŸŽถ Just a simple proxy server for not letting to abuse my SoundCloud client secrets.
JavaScript
1
star
59

vue2-examples

Playing with Vue 2.0 beta
JavaScript
1
star
60

izzit-mac-client

1
star
61

nooop

Just a noop function
JavaScript
1
star
62

fluid-layout-with-boxes

Small cross-browser hack in pure JS
JavaScript
1
star
63

universal-react-router-flux-2016

Opionated example of universal app setup
JavaScript
1
star
64

latest-browsers-api

JSON API to get the latest browser versions.
JavaScript
1
star
65

monqo-query-cli

make mongo shell queries from bash
JavaScript
1
star
66

contrabass.css

CSS utility belt in 1.99 kB
CSS
1
star
67

demo-tracker-app

demo of time tracker app written in angular
JavaScript
1
star
68

hamlet-boilerplate

App template for getting started with Hamlet
JavaScript
1
star
69

hash-unhash-exercise

JavaScript
1
star
70

angular_tuts

JavaScript
1
star
71

vapor-url-shortener

Basic url shortener API implemented in Swift and Vapor
1
star
72

webpack-trouble-demo

Webpack-dev-server + Existing node.js server = Some troubles
JavaScript
1
star