Git Product home page Git Product logo

ionic-ion-swipe-cards's Introduction

Ionic Contrib: Swipeable Cards

Swipeable card based layout for Ionic and Angular. As seen in apps like Jelly

Demo

Usage

Include ionic.swipecards.js after the rest of your Ionic and Angular includes. Then use the following AngularJS directives:

<swipe-cards>
  <swipe-card ng-repeat="card in cards" on-destroy="cardDestroyed($index)" on-card-swipe="cardSwiped($index)">
    Card content here
  </swipe-card>
</swipe-cards>

To add new cards dynamically, just add them to the cards array:

$scope.cards = [
  { // card 1 },
  { // card 2 }
];

$scope.cardDestroyed = function(index) {
  $scope.cards.splice(index, 1);
};

$scope.cardSwiped = function(index) {
  var newCard = // new card data
  $scope.cards.push(newCard);
};

ionic-ion-swipe-cards's People

Contributors

mhartington avatar mlynch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ionic-ion-swipe-cards's Issues

Doesn't work on ionic beta 12

Doesn't work on current ionic framework version; got:

Uncaught TypeError: Cannot read property 'ViewController' of undefined ionic.swipecards.js:26(anonymous function) ionic.swipecards.js:26(anonymous function) ionic.swipecards.js

Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module ionic.contrib.ui.cards due to:
Error: [$injector:nomod] Module 'ionic.contrib.ui.cards' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.17/$injector/nomod?p0=ionic.contrib.ui.cards
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:7649:12
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:9210:17
at ensure (http://localhost:2000/lib/ionic/js/ionic.bundle.js:9134:38)
at module (http://localhost:2000/lib/ionic/js/ionic.bundle.js:9208:14)
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:11382:22
at Array.forEach (native)
at forEach (http://localhost:2000/lib/ionic/js/ionic.bundle.js:7891:11)
at loadModules (http://localhost:2000/lib/ionic/js/ionic.bundle.js:11376:5)
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:11383:40
at Array.forEach (native)
http://errors.angularjs.org/1.2.17/$injector/modulerr?p0=ionic.contrib.ui.cā€¦%2Fionic.bundle.js%3A11383%3A40%0A%20%20%20%20at%20Array.forEach%20(native)
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:7649:12
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:11410:15
at Array.forEach (native)
at forEach (http://localhost:2000/lib/ionic/js/ionic.bundle.js:7891:11)
at loadModules (http://localhost:2000/lib/ionic/js/ionic.bundle.js:11376:5)
at http://localhost:2000/lib/ionic/js/ionic.bundle.js:11383:40
at Array.forEach (native)
at forEach (http://localhost:2000/lib/ionic/js/ionic.bundle.js:7891:11)
at loadModules (http://localhost:2000/lib/ionic/js/ionic.bundle.js:11376:5)
at createInjector (http://localhost:2000/lib/ionic/js/ionic.bundle.js:11316:11)
http://errors.angularjs.org/1.2.17/$injector/modulerr?p0=starter&p1=Error%3ā€¦3A%2F%2Flocalhost%3A2000%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A11316%3A11) ionic.bundle.js:7649

Swipe Cards Broken in Beta 14

With the update to Angular, the swipecards variable is not passed and therefore

swipeCards.pushCard(swipeableCard);

triggers a fatal error.

Titanium

I'm testing this swipe cards solution inside the Titanium cross platform, as a webview page, and always it was crashing while encrypting the JS files, so after a while I took out all the \lib\ionic\js\angular and angular-ui files and it's working now.
Don't know if it's a Titanium bug, but doing the same thing on a computer browser the demo works fine.

just can't get this to work... always get an error in the directive for swipe-card

I've done nothing but copy verbatim the example code. i've stripped down everything to just the very basics as you have in the example, but regardless, the directive for swipe-card fails becuase the swipe-cards argument to the directive is never valid...

so this the last argument (swipe-cards) on the compile function for the swipe-card directive line is just never properly set:
(line 297)
...
compile: function(element, attr) {
return function($scope, $element, $attr, swipeCards) {
var el = $element[0];
...

Cearly the swipe-card directive requires that it is contained within a swipe-cards(plural) directive.. and it is as i've only copy-pasted the example... so I always get this error:

[Error] Error: 'undefined' is not a function (evaluating 'swipeCards.pushCard(swipeableCard)')
http://code.ionicframework.com/contrib/ionic-contrib-swipecards/ionic.swipecards.js?v=5:297:30
http://localhost/bower_components/angular/angular.min.js:68:126
U@http://localhost/bower_components/angular/angular.min.js:68:178
C@http://localhost/bower_components/angular/angular.min.js:57:360
g@http://localhost/bower_components/angular/angular.min.js:50:20
http://localhost/bower_components/angular/angular.min.js:49:128
http://localhost/bower_components/angular/angular.min.js:50:509
k@http://localhost/bower_components/angular/angular.min.js:54:503
link@http://localhost/bower_components/angular/angular.min.js:231:181
http://localhost/bower_components/angular/angular.min.js:68:126
U@http://localhost/bower_components/angular/angular.min.js:68:178
C@http://localhost/bower_components/angular/angular.min.js:57:360
g@http://localhost/bower_components/angular/angular.min.js:50:20
C@http://localhost/bower_components/angular/angular.min.js:57:304
g@http://localhost/bower_components/angular/angular.min.js:50:20
g@http://localhost/bower_components/angular/angular.min.js:50:37
http://localhost/bower_components/angular/angular.min.js:49:128
http://localhost/bower_components/angular/angular.min.js:18:145
$eval@http://localhost/bower_components/angular/angular.min.js:121:193
$apply@http://localhost/bower_components/angular/angular.min.js:121:413
http://localhost/bower_components/angular/angular.min.js:18:107
e@http://localhost/bower_components/angular/angular.min.js:36:220
d@http://localhost/bower_components/angular/angular.min.js:18:28
kc@http://localhost/bower_components/angular/angular.min.js:18:317
Ad@http://localhost/bower_components/angular/angular.min.js:17:131
http://localhost/bower_components/angular/angular.min.js:241:154
j@http://localhost/bower_components/jquery/dist/jquery.min.js:2:27129
fireWith@http://localhost/bower_components/jquery/dist/jquery.min.js:2:54631
ready@http://localhost/bower_components/jquery/dist/jquery.min.js:2:29742
I@http://localhost/bower_components/jquery/dist/jquery.min.js:2:29927


(anonymous function) (angular.min.js, line 99)
(anonymous function) (angular.min.js, line 74)
U (angular.min.js, line 68)
C (angular.min.js, line 57)
g (angular.min.js, line 50)
(anonymous function) (angular.min.js, line 49)
(anonymous function) (angular.min.js, line 50)
k (angular.min.js, line 54)
link (angular.min.js, line 231)
(anonymous function) (angular.min.js, line 68)
U (angular.min.js, line 68)
C (angular.min.js, line 57)
g (angular.min.js, line 50)
C (angular.min.js, line 57)
g (angular.min.js, line 50)
g (angular.min.js, line 50)
(anonymous function) (angular.min.js, line 49)
(anonymous function) (angular.min.js, line 18)
$eval (angular.min.js, line 121)
$apply (angular.min.js, line 121)
(anonymous function) (angular.min.js, line 18)
e (angular.min.js, line 36)
d (angular.min.js, line 18)
kc (angular.min.js, line 18)
Ad (angular.min.js, line 17)
(anonymous function) (angular.min.js, line 241)
j (jquery.min.js, line 2)
fireWith (jquery.min.js, line 2)
ready (jquery.min.js, line 2)
I (jquery.min.js, line 2)

My html the quite obviously does have the proper nesting of the swipe-card directives nested within swipe-cards:

Help Out

<swipe-cards>
  <swipe-card on-card-swipe="cardSwiped()" id="start-card">
    Swipe down for a new card
  </swipe-card>
  <swipe-card ng-repeat="card in cards" on-destroy="cardDestroyed($index)" on-card-swipe="cardSwiped($index)">
    <div ng-controller="CardCtrl">
      <div class="title">
        {{card.title}}
      </div>
      <div class="image">
        <img ng-src="{{card.image}}">
      </div>
      <div class="button-bar">
        <button class="button button-clear button-positive" ng-click="goAway()">Answer</button>
        <button class="button button-clear button-positive" ng-click="goAway()">Decline</button>
      </div>
    </div>
  </swipe-card>
</swipe-cards>

Please throw me a bone here... 8 hours in and I can't get a cut-and-paste of the example to work at all.

regret swipe after started

First, I really love this swipe card script! its AWESOME!!

Card swipes despite I move the card back up (after regret swiping), please see referance of a good feeling slider with the ability to regret triggering swipe

https://github.com/bradbirdsall/Swipe/blob/master/swipe.js

several comments about behabior:

  • can do fast swipes (even if the distance between start and end is small)
  • when distance is short and the speed is slow it won't swipe
  • when start swiping and swipe back cancel swipe (unless the distance back is too short)

Hope you understood my issue. LOOOVE the IONIC framework!

P.S horisontal swipes can be nice as well

Swift left or right

Hi, how can I change the way of swiping the cards on right or left pls ?

Thanks.

The rAF function typo (?)

In trying to get the demo to work locally, I kept noticing the console showing issues with the window.rAF function not being found. So I snoop around and find that there IS a window._rAF function. I added the underscore in 3 places in the ionic.cards.js file starting at line 211 as below, and now it works.

screen shot 2014-05-29 at 5 42 22 pm

Android pre-5.0 rendering issues

I wrote up a forum post here, but I'd love to hear any recommendations on how to resolve this:

http://forum.ionicframework.com/t/android-rendering-woes-blurry-pre-5-0-only/19207

In a nutshell, on some Android devices pre-5.0, specifically I've tested 4.4.4 on both Genymotion images and real hardware, occasionally the swipecards render in a manner that could aptly be described as "obliterated". Sometimes swiping away and back again resolves it. Sometimes it doesn't.

Sometimes the card is rendered not quite as obliterated, but the text has anti-aliasing issues -- this seems to be a common issue with -webkit and transform3d

Adding card to back of stack

I am struggling to add a card, that is, hard coded into the html, that appears at the back of the stack. Even if I put my after the "card in cards" set of cards, it still appears first. Any ideas on how to do this?
Thanks,
Tom

Very low quality plugin (not useable for anything useful)

It is just me or are there so many issues with this plugin, I don't mean to be mean but this really not in a state to be used by anyone or is there a good fork somewhere

  • Adding cards dynamically the order is messed up
  • The new cards dont appear in a stack properly
  • There are no methods for swiping left or right programmatically
  • There are glitches everywhere
  • The onSwiped method is called inconsistently, sometimes not at all
  • Adding a new card like in the example really messes order up, animation happens sporadically

Just to name a few...

Breaks in 0.0.12

@mlynch

When my app gets booted up. the below error arises

Uncaught TypeError: Cannot read property 'ViewController' of undefined

The error arises from this line in swipecards.js

var SwipeableCardController = ionic.controllers.ViewController.inherit

Has the object name ionic.controllers changed to something? Or is it because ionic module not being injected?

Problem using with Side Menu

I am using this directive with a side menu at the same time. I have ion-side-menu-content(drag-content="false")and `ion-content.has-header(scroll="false")``

The problem is that the dragevent fires only once, i tried with different configurations without any succeed.

Xcode code signing error

With a recent Xcode update it seems certain executable files cause code signing to fail.

When submitting to the app store, this error is given. Removing the file and re-building fixes the error and submission is successful.

ERROR ITMS-90035: "Invalid Signature. Code object is not signed at all. The binary path [MyApp.app/www/lib/ionic-ion-swipe-cards/example/hooks/after_prepare/010_add_platform_class.js] contains an invalid signature..."

Easy solution may be to ignore the "example" folder in bower.json?

screenshot 2015-05-01 12 01 20

memory leak in SwipeCardController

Here's a codepen.io demo that uses the latest from this repo.

Open the console, inside the pushCard function I'm dumping this.cards and you'll see it grows on each swipe. I have a modified version of this component locally and I noticed the leak, and wanted to ensure it was a bug in the component and not something I added. It is the former.

It looks like you just aren't calling popCard in concert with a swipe event. I'm looking at a way to resolve it.

Can't get working with ionic.js v0.9.25

When I try and integrate with my project that's using 0.9.25 the swiping action doesn't work - throws up this error:

Uncaught TypeError: Object [object global] has no method 'rAF'

Reverting back to ionic.js 0.9.22-alpha fixes it, but then that causes a whole host of other problems with my project.

edit: 0.9.26 showing the same problem.

Help!

Card pops up but does not follow finger...

I have this problem where the cards are swipable but do not follow the finger like they follow the mouse pointer in the browser.

Anyone else encountered this problem?

getSwipebleCard works only once

When using the following code in the show controller:

var card = $ionicSwipeCardDelegate.getSwipebleCard($scope);
card.swipe();

it only works once, every other call will not make the current card swipe.

Not working on ionic framework beta 14

New Problems with beta.12

I have just updated to the new beta.12 version of Ionic and some errors have appeared regarding the ionic.swipecards plugin.

First i am receiving the following message:
Uncaught TypeError: Cannot read property 'ViewController' of undefined
on ionic.swipecards.js:26

the line reads: "var SwipeableCardController = ionic.controllers.viewController.inherit({"
so I am guessing the ionic.controllers has somehow change

further to this I also receive the following message which crushes the app completely:
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module ionic.contrib.ui.cards due to:
Error: [$injector:nomod] Module 'ionic.contrib.ui.cards' is not available! You......1)

I am guessing the two issues are related but cant figure out how to resolve the problem, any suggestions?

What all can i put on my cards?

example shows title and image... what if i want to have just html? like form elements? maybe i want like a multi-step form that one can just complete each step and swipe. is that possible? i don't see it discussed anywhere... or is it only title and image and that's it?

ionic-ion-swipe-cards not working

Hey,

Here are my controllers
myApp.controller('MyCardsCtrl', function($scope, $http, $ionicSwipeCardDelegate) {

console.log('MyCardsCtrl');

$scope.cards = [];

$scope.addCard = function(img, name) {
var newCard = {image: img, title: name};
newCard.id = Math.random();
$scope.cards.unshift(angular.extend({}, newCard));
};

$scope.addCards = function(count) {
$http.get('http://api.randomuser.me/?results=' + count).then(function(value) {
angular.forEach(value.data.results, function (v) {
$scope.addCard(v.picture.medium, v.email);
});
$scope.showCards = true;
console.log($scope.cards);
});
};

$scope.addCards(1);

$scope.cardSwiped = function(index) {
$scope.addCards(1);
console.log('cardSwiped');
console.log($scope.cards);
};

$scope.cardDestroyed = function(index) {
$scope.cards.splice(index, 1);
};
})

myApp.controller('MyCardCtrl', function($scope, $ionicSwipeCardDelegate) {
$scope.doAnything = function() {
var card = $ionicSwipeCardDelegate.getSwipeableCard($scope);
card.swipe();
};
});

below is my html content

Swipe down for a new card
{{card.title}}
Like Disklike

Need help in fixing the issue. I used the same css mentioned in the https://devdactic.com/swipeable-cards-ionic/

Strange transitions animations

I dont know if it is because of the new version of ionic, but the transitions are very strange in my project. Not popping up and everything.

Multi-direction Swipe

It would be nice for the library to support swipe action in any direction, so we could bind other actions and build an UI around that.

Very nice performance by the way. Glad to see somebody actually making something feel native using HTML5.

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.