Hoppa till innehåll

Making Tinder Style Swipe Cards With Ionic Framework

  • av
Making Tinder Style Swipe Cards With Ionic Framework

The Tinder App recently got large amount of attention, particularly the swipe cards are instantly showing up everywhere. Ionic has already been producing an answer for all to create these kind easily of cards with HTML5 and Javascript. Consequently, in this tutorial we will highlight simple tips to include swipe that is tinder-style in your Ionic software by using a customized ion.

You will find the current project for ionic-ion-tinder-cards on github. Nonetheless, the demo is a little buggy as well as the paperwork right now just isn’t extremely detail by detail, so follow along this tutorial to have a sweet card optic such as this:

Setup your base App

We focus on a simple blank Ionic template and include the iOS and Android os system:

Now we have to install the the Ionic tinder cards, generally speaking i favor it to put in these packages via bower therefore go right ahead and kind:

This may not just install the Ionic tdcards, but in addition the collide.js lib which can be utilized in the tinder cards. We have to import both inside our software, therefore available your index.html and include the lines:

Incorporating the tinder cards

To demonstrate any such thing, we must modify our index.html you need to include the customized directives. Substitute every thing in the physical human body with:

We add cards for products within our range array, and additional we set some occasions when it comes to actions the cards get. These are generally quite explaining that is self i need to point out that some occasions go to the website don’t get totally proper brought about by now. I believe we will have an improvement on these components within the future that is near.

Within the card we now have some div elements, but we will started to the styling later on in this guide. The essential component right here is to own at least the yes-text and no-text class, because they are targeted within the tinder cards collection. In the event that you don’t utilize them, you’ll see plenty of JavaScript mistakes in your system!

Also we add the ‘no-scroll’ directive to your human body, so that you don’t scroll the information it self but just the cards. We determine this within our app.js and also inject the dependency into the tinderCards:

Now just the controller we assigned to your content is lacking. Therefore go on and include this to your app.js:

Absolutely absolutely absolutely Nothing unique in here. We define our array with cardtypes (you are able to find the pictures into the associated github repo) and add the 3 cards to the range array for the ng-repeat we defined into the index. One other functions will be the people we assigned to your swipe activities. You really swipe the card out fast for me, the cardDestroyed seems to work always while the other two only get called when.

The state Ionic demo additionally adds a brand new card whenever one was destroyed/swiped down, but that results in strange UI behavior for me personally. When I stated before, you will see absolutely updates in the foreseeable future.

Include some customized styling

Final thing lacking happens to be some CSS. You saw at the beginning of this post if you run your app by now, the appearance won’t be close to what. Perhaps more components of the design will undoubtedly be contained in next releases, for now include this to your app.css:

As a whole, we now have two components right right here: The styling and position associated with card component, therefore the styling for a small overlay whenever you begin dragging the cards. You are able to experiment along with elements to match your requirements, for me personally it was somehow a result that is acceptable. Now get ahead an run your software, and you ought to have three cool styled tinder cards! Did you spot the little influence on the card stack whenever you drag the very first card? Yes, Ionic posseses attention for details.

If you wish to look at tinder cards for action, you’ll have a consider my implementation on Heroku or deploy it straight to your Heroku.

Summary

This guide explained steps to make Tinder design cards with Ionic, in just some directives and customized styling. Nevertheless, you can still find some true points which should be fixed. The swiping isn’t constantly triggered properly, and a key to programmatically pop the most notable card had not been working at this point. This will be an attribute you most definitely constantly want whenever using cards like these.

If you prefer this tutorial or have any questions go ahead and comment, follow me on twitter @schlimmson or take a look at my weblog Devdactic to see more tutorials about Ionic as well as other fancy frameworks!

Lämna ett svar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *