Socket
Socket
Sign inDemoInstall

swipe-it

Package Overview
Dependencies
30
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    swipe-it

Swipe a custom element out with animation


Version published
Weekly downloads
2
Maintainers
1
Install size
4.10 MB
Created
Weekly downloads
 

Readme

Source

Swipe-it

Swipe a custom element out.

NPM version Dependency Status Build Status Coverage Status

Give me a feed back if you have any problem with this.

Demo

Features

  • Animation like ios messages
  • Light weight and performance optimized
  • Delegate event binding
  • Custom animation
  • Custom render function
  • Support window orientation change & resize event
  • Works with sweet-sortable
  • Optional bind to list-render
  • Temporarily disable by calling bind and unbind

Example

var tap = require('component-tap-event')
var SwipeIt = require('swipe-it')
var template = require('./template.html')
var s = new SwipeIt(template)
s.bind(document.getElementById('list'), 'li')
s.delegate('touchstart', '.remove', tap(function(e, li) {
  // remove holder and swiped element with transition
  s.clear().then(function() {
    // callback on element removed
  })
}))

Events

  • start emit with swipe element when swipe start
  • end emit with swipe element after swiped element reset back
  • clear emit with swipe element just before remove transition begin, used for change the style of swiped element for transition

API

SwipeIt(template, [opts])

  • template string or element for element swiped out
  • opts optional options
  • opts.ease a ease function or string for reset&expand animation, default out-quad
  • opts.duration duration for reset in millisecon, default 350

.bind(parentNode, selector)

Bind swipe event to parentNode with delegated selector

.bind(ListRender, selector)

Bind to listRender instance, which enables automate model reative-lite bind

.ignore(selector)

Ignore touchstart event from target that within element matches selector

.render(fn)

Set a optional render function for swiped out element , fn is passed with related swiped element(which matches the bind selector) and template string, fn should return an element

.delegate(type, selector, handler)

Delegate handler of type event with matched selector within swiped out element, handler is called with original event and related swiped element.

.reset()

Reset the swiped element to original stat with animation, return promise

.clear([duration], [ease])

Remove the swiped element and related holder with transition specified by duration (default 300) in millisecond and ease timing function, return promise.

.unbind()

Unbind all event listeners, and reset status synchronizely, could be active again be calling bind

Keywords

FAQs

Last updated on 01 Aug 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc