Build a Tinder-Like Swipe UI for Angular/Ionic 4. Tinder’s swiper is a of good use ui component.


Build a Tinder-Like Swipe UI for Angular/Ionic 4. Tinder’s swiper <a href=""></a> is a of good use ui component.

Tinder’s swiper is a helpful ui component. Build it for your Angular/Ionic 4 application

what are the four bases in dating

At a level that is high I made the decision to separate the task into four components:

placeholder) template and TS rule with this component, put it in a Ionic app web web page ( by having a switch, that will “load” Tinder cards’ information in to the component.

Therefore, the final final result should appear to be this:

Let’s begin, there was a complete great deal to pay for!

Part 1: Create Initial Templates

Let’s start with forking this StackBlitz’s Ionic 4 template. It offers A website first of all and we’ll include a fresh Angular aspect of it:

As seen through the above, we now have added component that is tinder-ui the template, that will have cards property (we shall implement it within our component utilizing Angular’s Input), in addition to a choiceMade listener. (It’s going to be implemented via Angular’s production).

Plus, we included a button that is simple we shall used to simulate “loading” of cards into our component

Now, let’s stab our tinder-ui component. (We are going to produce three files: tinder-ui-component’s HTML, SCSS, and TS) and include it to home.module.ts :


dating a pregnancy

Therefore, we just included all the divs and their respectful classes right here, plus included binding towards the root div to cards.length -> making the component that is entire if the card’s length is zero.


Our CSS guidelines can help align all the things and work out it all look appropriate for the swiper.

I will be perhaps not too good with styling so you could have an improved approach right here, particularly if you want to go after a responsive UI. But also for our situation right here, these should really be enough.


Therefore, a notes that are few:

Given that the beds base of our component is prepared, we have to include it to the home.module.ts :

Component 2: Implementing the View for Stacked Cards

Because of this execution, we are going to assume that each and every card just has a graphic, name, and description and therefore our cards array (repository from your ) may have the after program:

According to this, we’re going to now implement the card’s that is stacked inside tinder-ui.component.html .

We shall leverage the *ngFor directive to replicate cards and certainly will utilize the [ngStyle] binding coupled using the index of every card to make them in the shape of a stack:

We will also put in a template guide tinderCardImage to your element therefore it up with ViewChildren in our TS code that we could pick.

Finally, we included a simple (load) listener to guarantee the image is shown (opacity 1) only once this has completely packed. This can be a lot more of a nice-to-have for the look that is smoother feel.

Now you should be ready to test the scene regarding the stack of cards. For that, we shall bind our key inside to an approach that may load some placeholder data:

Chances are, we have to be in a position to click on the LOAD TINDER CARDS key to check out the below:

Component 3: Implementing Yes/No Buttons With Animation

We’re going to assume the image of the “heart” for the YES and image of a” that is“cross a NO response by our individual.

Because of this implementation, I made the decision to simply make use of A svg image and inline it for the Tinder buttons (those would be the white sectors above) and for the Tinder — status, that will be a powerful indicator that may show an individual exactly exactly what their response is likely to be while dragging.

Therefore, now we have been inlining the SVGs that represent one’s heart and cross, also including a ( transitionend ) occasion listener to every card even as we just like to work regarding the cards (such as for example to eliminate the card from our stack) in case where animation for the change has completely ended.

Finally, we shall add the opacity that is[style] binding which will surely help us expose choice indicators as soon as we require them.

Updated html that is tinder-ui.component

Now we have been willing to alter our TS file using the button-pressed logic because well as with some more perks:

The userClickedButton technique right right here ought to be clear to see: if our user clicked “yes” (the center), we add transform to your card that is top] ) and force it to begin traveling away off to the right.

If “no” is clicked, the card flies to your remaining side. Now, whenever this type of change will end, our other method handleShift will eliminate this type of card considering that the state that is shiftRequired real .

Finally, here the toggleChoiceIndicator is called by us technique, helping to make the Tinder status SVG noticeable for an individual within the screen’s center.

Part 4: Implement Dragging and Selection Production

The ultimate implementation action could be the feature that is dragging. Make it possible for it, we shall make use of the Hammer.js pan motion, that used to participate the Ionic framework, nevertheless now calls for split installation:

The above shall install the package then you should just include listed here to your main.ts :

With Hammer enabled, we are able to include ( pan ) and ( panend ) input motion audience into the tinder — cards div:

Now we could include the strategy handlePan and handlePanEnd to our tinder-ui.component.ts in includeition to add the logic to give off the user’s choices:


Using the last few modifications, our rule happens to be complete and may be leveraged inside an Ionic 4 or pure Angular application.

Comments are closed.