Build a Tinder-Like Swipe UI for Angular/Ionic 4. Tinders swiper is just a helpful ui component.

Build a Tinder-Like Swipe UI for Angular/Ionic 4. Tinders swiper is just a helpful ui component.

Tinders swiper is really A ui that is useful component. Build it for your Angular/Ionic 4 application

jeff probst dating contestant

At a advanced, I decided to divide the job into four components:

placeholder) template and TS rule because of this component, put it inside an Ionic app web web page ( with a key, that will load Tinder cards data in to the component.

Therefore, the final result should appear to be this:

Lets begin, there clearly was great deal to pay for!

Part 1: Create Initial Templates

Lets begin by forking this StackBlitzs Ionic 4 template. This has A website to begin with and we’ll include an innovative new Angular aspect of it:

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

Plus, we included a button that is simple we are going to used to simulate loading of cards into our component

Now, lets stab our tinder-ui component. (we shall produce three files: tinder-ui-components HTML, SCSS, and TS) and include it to home.module.ts :


libra woman dating pisces man

Therefore, we just added all the divs and their respectful classes right here, plus included binding to your root div to cards.length -> making the component that is entire if the cards length is zero escort service Simi Valley.


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

I’m not too good with styling so you may have an improved approach here, particularly if you intend to decide on a responsive UI. But also for our situation right right here, these must be adequate.


So, several records right here:

Given that the beds base of y our component is prepared, we must include it to the house.module.ts :

Component 2: Implementing the View for Stacked Cards

With this execution, we shall assume that each and every card has only a picture, name, and description and that our cards array (repository from your ) may have the interface that is following

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

We will leverage the *ngFor directive to replicate cards and can make use of the [ngStyle] binding coupled aided by the index of every card to make them in the shape of a stack:

We will also put in a template guide tinderCardImage to the 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 if it offers completely packed. This is certainly a lot more of a nice-to-have for a look that is smoother feel.

Now you should be willing to test the view associated with stack of cards. For the, we shall bind our key inside to a way which will load some placeholder information:

Right now, you should be in a position to click on the LOAD TINDER CARDS key and determine the below:

Component 3: Implementing Yes/No Buttons With Animation

We shall assume the image of the heart for the YES and image of a that iscross a NO solution by our individual.

Because of this execution, I made a decision to simply utilize A svg image and inline it for the Tinder buttons (those will be the white groups above) and for the Tinder status, which can be a powerful indicator that may show the consumer 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, in addition to adding a transitionend that is( occasion listener every single card once we just wish to work in the cards (such as for instance to get rid of the card from our stack) in the event where animation for the change has completely ended.

Finally, we shall add the [style.opacity] binding which can only help us expose option indicators whenever we require them.

Updated html that is tinder-ui.component

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

The userClickedButton technique right here must certanly be clear to see: if our user clicked yes (the center), we add transform to the 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 part. Now, whenever this kind of change will end, our other method handleShift will eliminate this kind of card because the shiftRequired state ended up being real .

Finally, right here we call the toggleChoiceIndicator technique, helping to make the Tinder status SVG noticeable for the consumer in the screens center.

Component 4: Implement Dragging and Solution Production

The last execution action may 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, however now calls for installation that is separate

The above mentioned will install the package and after that you simply need to include the next to your main.ts :

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

Now we are able to include the strategy handlePan and handlePanEnd to our tinder-ui.component.ts in addition to add the logic to give off the users choices:


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

Leave a Reply