Socket
Socket
Sign inDemoInstall

swipe-it

Package Overview
Dependencies
32
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.14 to 0.1.15

2

example/index.js

@@ -26,3 +26,2 @@ var scrollfix = require('scrollfix')

sortable.bind('li')
//sortable.ignore('.swipe-dragging')

@@ -43,2 +42,3 @@ var swipe = SwipeIt(template, {

}))
swipe.active(list.querySelector('li:first-child'))
})()

@@ -45,0 +45,0 @@

@@ -0,1 +1,4 @@

0.1.15
* add active method
0.1.14

@@ -2,0 +5,0 @@ * no swipe for absolute element

@@ -131,29 +131,49 @@ var domify = require('domify')

this.prevX = sx
// show template and bind events
var pel = util.getRelativeElement(el)
var holder = this.holder = createHolder(el)
this.swipeEl = el
if (this.renderFn) {
this.renderFn(holder)
} else {
holder.appendChild(this.templateEl)
}
var templateEl = this.templateEl
util.copy(templateEl.style, {
position: 'absolute',
bottom: '0',
right: '0'
})
templateEl.style.height = holder.style.height
this.bindEvents(holder)
this.orig = util.makeAbsolute(el, pel)
classes(el).add('swipe-dragging')
el.parentNode.insertBefore(holder, el)
this.bindReactive(el, templateEl)
this.min = - templateEl.clientWidth - overlap
this.emit('start', el)
this._start(el)
}
}
SwipeIt.prototype._start = function (el) {
this.swipeEl = el
// show template and bind events
var pel = util.getRelativeElement(el)
var holder = this.holder = createHolder(el)
var templateEl = this.templateEl.cloneNode(true)
if (this.renderFn) {
this.renderFn(holder)
} else {
holder.appendChild(templateEl)
}
util.copy(templateEl.style, {
position: 'absolute',
bottom: '0',
right: '0'
})
templateEl.style.height = holder.style.height
this.bindEvents(holder)
this.orig = util.makeAbsolute(el, pel)
classes(el).add('swipe-dragging')
el.parentNode.insertBefore(holder, el)
this.bindReactive(el, templateEl)
this.min = - templateEl.clientWidth - overlap
this.emit('start', el)
}
/**
* Swipe out an element el with optional `ease` and `duration`
*
* @public
* @param {Element} el
* @param {String} ease [out-quad]
* @param {Number} duration [350]
* @return {Promise}
*/
SwipeIt.prototype.active = function (el, ease, duration) {
this._start(el)
ease = ease || this.opts.ease
var minX = this.min + overlap
return this.animate(minX, ease, duration)
}
/**
* @param {Event} e

@@ -253,3 +273,3 @@ * @private

SwipeIt.prototype.unbindEvents = function () {
if (this.holderEvents) this.holderEvents.unbind()
if (this.holderEvents != null) this.holderEvents.unbind()
this.holderEvents = null

@@ -259,3 +279,3 @@ }

/**
* Calcute swipe speed and direction with clientX clientY
* Calcute swipe speed and direction with ts and prevX
*

@@ -519,5 +539,7 @@ * @param {Number} x

if (!this.reactive) {
var r = this.reactive = new Reactive(templateEl, model, opts)
// no parse template again
opts.config = r.config
} else {
this.reactive = new Reactive(templateEl, model, opts)
} else {
this.reactive.bind(model)
}

@@ -524,0 +546,0 @@ }

@@ -65,4 +65,4 @@ var doc = document.documentElement

top: r.top -rect.top,
width: r.width || el.offsetWidth,
height: r.height || el.offsetHeight
width: r.width,
height: r.height
}

@@ -69,0 +69,0 @@ }

{
"name": "swipe-it",
"version": "0.1.14",
"version": "0.1.15",
"description": "Swipe a custom element out with animation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -84,2 +84,9 @@ /*global describe, it, before, after, beforeEach, afterEach*/

})
it('should throw if bind list invalid', function () {
var s = SwipeIt(domify(template))
expect(function(){
s.bind('invalid', 'li')
}).toThrow(/invalid/)
})
})

@@ -255,5 +262,6 @@

var touch = new TouchSimulate(first)
touch.speed(200)
return swipe.reset().then(function () {
return touch.start().moveLeft(10).wait(500).then(function () {
var el = swipe.parentNode.querySelector('li:nth-child(2)')
return touch.start().moveLeft(40).wait(400).then(function () {
var el = swipe.parentNode.querySelector('li:last-child')
expect(el).toNotBe(first)

@@ -652,1 +660,33 @@ var t = new TouchSimulate(el)

})
describe('.active', function() {
var swipe
var list
var span
beforeEach(function () {
var template = '<div class="remove" style="width:70px;">x</div>'
list = createList()
var first = list.firstChild
span = document.createElement('span')
span.className = 'handle'
first.appendChild(span)
swipe = SwipeIt(template)
swipe.bind(list, 'li')
})
afterEach(function () {
document.body.removeChild(list)
list = span = swipe = null
})
it('should swipe out', function () {
var first = list.querySelector('li:first-child')
var promise = swipe.active(first)
return promise.then(function () {
var el = list.querySelector('.remove')
expect(el).toExist()
expect(swipe.swipeEl).toBe(first)
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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