Giter VIP home page Giter VIP logo

swiped's Introduction

Swiped.js

license npm

swiped.js qrcode

Demo (use mobile or emulate touches mode on your browser)

swiped.js

Features

  • Dependency-free.
  • Short & long swipe.
  • Swipe to delete.
  • Easy to use.
  • CSS transforms & transitions.

Installation

npm install swiped
bower install swiped

API

Swiped(options)

  • options (object) - Options to configure a new instance of Swiped.
  • [options.query] (string) - Query selector.
  • [options.duration] (number) - The time (milliseconds) to open/close the element. Default: 200.
  • [options.tolerance] (number) - Default: 150.
  • [options.time] (number) - Time for short swipe. Default: 200.
  • [options.left] (number) - Distance for swipe from left to right. Default: 0.
  • [options.right] (number) - Distance for swipe from right to left. Default: 0.
  • [options.list] (boolean) - Elements depend on each other. Default: false.
  • [options.onOpen] (function).
  • [options.onClose] (function).
var s = Swiped.init(options);

s.open();
s.close();
s.toggle();
s.destroy([isRemoveNode])

Usage

Example of the html markup for single element:

<div class="foo">
    elem1
</div>

for multiple:

<ul class="bar">
    <li>
        elem3
    </li>
    <li>
        elem4
    </li>
    <li>
        elem5
    </li>
</ul>

for switch:

<div class="foo"><span></span>element 16</div>

initialization for single element:

var s1 = Swiped.init({
    query: '.foo',
    right: 300
});

for multiple:

var s2 = Swiped.init({
    query: '.bar li',
    list: true,
    left: 200,
    right: 200
});

for switch:

var s3 = Swiped.init({
    query: '.foo',
    left: 400
});

document.querySelector('.foo span').addEventListener('touchstart', function() {
    s3.toggle();
});

Implementation for "swipe to delete"

Swiped.init({
    query: '.baz',
    right: 400,
    onOpen: function() {
        this.destroy(true)
    }
});

swiped's People

Contributors

mishk0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.