npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

swipe-to-delete

v0.1.6

Published

Implement the 'swipe to delete' UI-pattern in the Marionette framework.

Downloads

19

Readme

Swipe-to-delete Marionette View

Implement the "swipe to delete" UI-pattern in the Marionette framework.

Example

You may see an example here.

Usage

This is a plugin built on top of the base Marionette LayoutView. It contains two regions: "content" and "delete". A content region show your a view. A delete region show a decoration view under the content view. It's showed when content view is swiped.

Usually, the swipe-to-delete view is used in the Marionette CollectionView.

var collectionView = Backbone.Marionette.CollectionView.extend({
	childView: SwipeToDeleteView.default,
	childViewOptions: function () {
		return {
			View: MessageView
		};
	}
});
  • childView contains the swipe-to-delete Marionette view.
  • childViewOptions returns its options.

Include lib

It's available on SwipeToDeleteView.default.

CommonJS

var SwipeToDeleteView = require('swipe-to-delete');
// SwipeToDeleteView.default

AMD

define(['swipe-to-delete'], function(SwipeToDeleteView) {
	// SwipeToDeleteView.default
});

Global

<script src="node_modules/swipe-to-delete/dist/swipe-to-delete.min.js"></script>
<script>
// SwipeToDeleteView.default
</script>

Options

  • View - This must be your a view object definition, not an instance. It can be any Backbone.View or be derived from Marionette.ItemView. Required.
  • DeleteView - This is a decoration view object definition under a content view. By default, showed red element with trash icons. Optional.
  • deleteSwipe - This is a number. If a content view is swiped more this the number than a swipe-to-delete view will start a delete animation. By default, it's equal "0.5". Optional.

Events

The swipe-to-delete view triggers following events on a content view:

  • swipe:delete - when a delete animation is ended. It's used to destroy entity.
onSwipeDelete: function () {
	this.model.destroy();
}
  • swipe:cancel - when a cancel animation is ended.

Styles

You may set up styles in "swipe-to-delete.css" under the comment "Custom styles". The class js-content is content region, js-delete is delete region. Classes js-transition-delete-right and js-transition-delete-left are added on a content view when it's swiped more than "deleteSwipe" options. Class js-transition-cancel is added when a content view swiped less than "deleteSwipe" options. Animations are made by CSS3 transition.

Downloads

Swipe-to-delete is available via bower and npm. Else you can download the latest builds directly from the "dist" folder above.

Contributing

From opening a bug report to creating a pull request: every contribution is appreciated and welcome. If you're planing to implement a new feature or change the api please create an issue first.

License

MIT