GithubHelp home page GithubHelp logo

miguelramosfdz / angular-swing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gajus/angular-swing

0.0 2.0 0.0 922 KB

AngularJS directive for Swing: A swipeable cards interface. The swipe-left/swipe-right for yes/no input. As seen in apps like Jelly and Tinder, and many others.

License: Other

CSS 51.40% JavaScript 48.60%

angular-swing's Introduction

angular-swing

NPM version Bower version

AngularJS directive for Swing: A swipeable cards interface. The swipe-left/swipe-right for yes/no input. As seen in apps like Jelly and Tinder, and many others.

Give it a swing! and please tweet it if you like it. : )

Card stack example.

Usage

Include ./dist/angular-swing.js..

Load gajus.swing module, e.g.

angular.module('your-module', ['gajus.swing']);

Loading gajus.swing module will make available the swing-stack and swing-card directives.

Prepare a Swing stack:

<ul swing-stack></ul>

Add a Card to the Swing stack:

<ul swing-stack>
    <li swing-card></li>
</ul>

Attach event listeners to the instance of Card:

<ul swing-stack>
    <li
        swing-card
        swing-on-throwout="console.log(eventName, eventObject)"
        swing-on-throwoutleft="console.log(eventName, eventObject)"
        swing-on-throwoutright="console.log(eventName, eventObject)"
        swing-on-throwin="console.log(eventName, eventObject)"
        swing-on-dragstart="console.log(eventName, eventObject)"
        swing-on-dragmove="console.log(eventName, eventObject)"
        swing-on-dragend="console.log(eventName, eventObject)"
        ></li>
</ul>

Use scope variables/methods to add/remove cards:

<ul swing-stack>
    <li
        swing-card
        swing-on-throwout="remove($index)"
        ng-repeat="card in cards"
        >{{card.name}}</li>
</ul>
$scope.cards = [
    {name: 'foo'},
    {name: 'bar'}
];
$scope.remove = function (index) {
    $scope.cards.splice(index, 1);
}
$scope.add = function (name) {
    $scope.cards.push({name: name});
};

Examples

There are more examples that using the standalone Swing.

The code for all of the examples is in the ./examples/ folder.

Raise an issue if you are missing an example.

Events

Swing Documentation for the Events.

Swing events translate to the following attributes in the AngularJS directive:

Name Description
throwout swing-on-throwout
throwoutleft swing-on-throwoutleft
throwoutright swing-on-throwoutright
throwin swing-on-throwin
dragstart swing-on-dragstart
dragmove swing-on-dragmove
dragend swing-on-dragend

Event listener expression can use eventName and eventObject parameters.

Event Object

Swing Documentation for the Event Object.

Download

Using Bower:

bower install angular-swing

Using NPM:

npm install angular-swing

angular-swing's People

Contributors

gajus avatar mubashariqbal avatar

Watchers

 avatar  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.