An Ion (reusable Ionic widget) for adding tinder-style swipe cards to your app.
Forked from Ionic's Pen Ionic Ion: Tinder Cards.
Forked from Ionic's Pen Ionic Ion: Tinder Cards.
A Pen by aaron k saunders on CodePen.
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> | |
| <link href="//code.ionicframework.com/1.0.0-beta.14/css/ionic.css" rel="stylesheet"> | |
| <script src="http://code.ionicframework.com/collide/0.0.4/collide.js"></script> | |
| <script src="//code.ionicframework.com/1.0.0-beta.14/js/ionic.bundle.js"></script> | |
| <script src="https://rawgit.com/driftyco/ionic-ion-tinder-cards/master/ionic.tdcards.js"></script> | |
| </head> | |
| <body ng-app="tinder" no-scroll> | |
| <ion-pane ng-controller="CardsCtrl"> | |
| <ion-header-bar class="bar-default"> | |
| <h1 class="title">Tinder Cards</h1> | |
| </ion-header-bar> | |
| <ion-content scroll="false"> | |
| <div ng-if="cardsLoaded"> | |
| <td-cards> | |
| <td-card id="td-card" class="td-card td-card--index-{{$index}}" ng-repeat="card in cards" on-transition-left="cardDislike(card)" on-transition-right="cardLike(card)" on-transition-out="fadeCard()" on-destroy="removeCard($index)"> | |
| <div class="card"> | |
| <figure class="item item-image"> | |
| <img ng-src="{{card.image}}"> | |
| <div class="td-card__overlay td-card__overlay--dislike no-text">Dislike</div> | |
| <div class="td-card__overlay td-card__overlay--like yes-text">Like</div> | |
| </figure> | |
| <ion-item> | |
| <p>Add some information here</p> | |
| </ion-item> | |
| </div> | |
| </td-card> | |
| </td-cards> | |
| </div> | |
| </ion-content> | |
| <ion-footer-bar class="padding"> | |
| <div class="row"> | |
| <div class="col"> | |
| <button class="button button-block">GOING</Button> | |
| </div> | |
| <div class="col"> | |
| <button class="button button-block">MAYBE</Button> | |
| </div> | |
| <div class="col"> | |
| <button class="button button-block">NOT GOING</Button> | |
| </div> | |
| </div> | |
| </ion-footer-bar> | |
| </ion-pane> | |
| </body> | |
| </html> |
An Ion (reusable Ionic widget) for adding tinder-style swipe cards to your app.
Forked from Ionic's Pen Ionic Ion: Tinder Cards.
Forked from Ionic's Pen Ionic Ion: Tinder Cards.
A Pen by aaron k saunders on CodePen.
| angular.module('tinder', ['ionic', 'ionic.contrib.ui.tinderCards']) | |
| .controller('CardsCtrl', function($scope, $http) { | |
| $scope.cards = []; | |
| $scope.cardsLoaded = false; | |
| $scope.addCard = function(image) { | |
| var newCard; | |
| newCard = { | |
| 'image': image | |
| }; | |
| $scope.cards.unshift(angular.extend({}, newCard)); | |
| }; | |
| $scope.addCards = function(count) { | |
| $http.get('http://api.randomuser.me/?results=' + count).then(function(users) { | |
| $scope.cardsLoaded = true; | |
| angular.forEach(users.data.results, function(card) { | |
| $scope.addCard(card.user.picture.large); | |
| }); | |
| }); | |
| }; | |
| $scope.addCards(3); | |
| $scope.cardLike = function(card) { | |
| $scope.addCards(1); | |
| }; | |
| $scope.cardDislike = function(card) { | |
| $scope.addCards(1); | |
| }; | |
| $scope.removeCard = function($index) { | |
| $scope.cards.splice($index, 1); | |
| }; | |
| $scope.fadeCard = function($index) { | |
| this.swipeCard.el.style.opacity = 0 | |
| } | |
| }) | |
| ; |
| .td-cards { | |
| max-width: 420px; | |
| margin: 0 auto; | |
| position: relative; | |
| } | |
| .td-card { | |
| position: absolute; | |
| width: 100%; | |
| display: block; | |
| } | |
| .td-card img { | |
| max-width: 100%; | |
| max-height: 100%; | |
| } | |
| .td-card__overlay { | |
| position: absolute; | |
| top: 50%; | |
| z-index: 10; | |
| opacity: 0; | |
| font-size: 20px; | |
| padding: 20px; | |
| margin-top: -30px; | |
| background: rgba(255,255,255,0.8); | |
| } | |
| .td-card__overlay--like { | |
| color: green; | |
| left: 0; | |
| } | |
| .td-card__overlay--dislike { | |
| color: tomato; | |
| right: 0; | |
| } |