Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <evil-tinder></evil-tinder>
              
            
!

CSS

              
                @import 'https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css';
@import url('https://fonts.googleapis.com/css?family=Montserrat');

html {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

body {
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  position: relative;
}
button:focus {outline:0;}


/* EVIL TINDER COMPONENT */
evil-tinder {
  display: flex;
  justify-content: flex-start;
  height: 100vh;
  flex-direction: column;
  font-family: 'Montserrat', sans-serif;
}

.header {
  flex-shrink: 0;
  height: 80px;
  background:  url('https://canjs.com/docs/can-guides/commitment/recipes/tinder-like-carousel/img/evil-tinder-logo.svg') no-repeat center;
  background-size: auto 55%;
  border-bottom: 1px dotted lightgray;
}

.images {
  position: relative;
  flex-grow: 1;
  flex-shrink: 1;
  display: flex;
}

.footer {
  flex-shrink: 0;
  margin: 25px 0 30px;
  display: flex;
  justify-content: center;
  align-self: center;
  height: 100px;
  width: 100%;
  background: #f7f7f7;
  z-index: 9999;
}


.current, .next {
  top: 0px;
  z-index: 100;
  
}
.current {
  position: absolute; 
  display: flex;
  top: 0px;
  bottom: 0px;
}
.next {
  z-index: 99;
  margin-top: 15px;
  position: relative;
  
}

.current img, .next img {
  object-fit: cover;
  object-position: 50% 0%;
  border-radius: 10px;
  box-shadow: 0px 0px 0px 2px rgba(240,240,240,1);
}

.current img {
  width: 96vw;
  margin: 2vw;
}


.next img {
  height: 100%;
  width: 94vw;
  margin: 1vw 3vw;
}
.result {
}
.liking:after {
  font-size: 25vw;
  content: "Like";
  padding: 10px 26px;
  color: #73c998;
  border: #73c998 2vw solid;
  margin-top: 100px;
  z-index: 9999;
  display: inline-flex;
  position: absolute;
  border-radius: 30px;
  text-shadow: 0px 0px 15px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.75);
  opacity: 1;
  transform: scale(1) rotate(-7deg);
  animation: resultAnim .8s ease-in-out;
}
.noping:after {
  font-size: 25vw;
  content: "Nope";
  padding: 6px 26px 16px;
  color: #ed7571;
  border: #ed7571 2vw solid;
  margin-top: 100px;
  z-index: 9999;
  display: inline-flex;
  position: absolute;
  border-radius: 30px;
  text-shadow: 0px 0px 15px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.75);
  opacity: 1;
  transform: scale(1) rotate(-7deg);
  animation: resultAnim .8s ease-in-out;
}
@keyframes resultAnim {
  0% {
    transform: scale(3) rotate(0deg);
    opacity: 0.2;
  }
  100% {
    transform: scale(1) rotate(-7deg);
    opacity: 1;
  }
}


.likeBtn {
  border-radius: 50%;
  height: 115px;
  width: 115px;
  box-shadow: 0px 0px 0px 20px rgba(240,240,240,1);
  border: none;
  padding: 20px;
  margin: 0 10px;
  background:  url('https://canjs.com/docs/can-guides/commitment/recipes/tinder-like-carousel/img/heart.svg') no-repeat center;
  background-size: auto 55px;
  color : transparent;
	font-size : 0;
}
.dissBtn {
  border-radius: 50%;
  height: 115px;
  width: 115px;
  box-shadow: 0px 0px 0px 20px rgba(240,240,240,1);
  border: none;
  padding: 50px;
  margin: 0 10px;
  background:  url('https://canjs.com/docs/can-guides/commitment/recipes/tinder-like-carousel/img/close.svg') no-repeat center;
  background-size: auto 50px;
  color : transparent;
	font-size : 0;
}

@media screen 
  and (min-width: 320px) 
  and (max-width: 890px) {
    .undoBtn, .superBtn {
      height: 40px;
      width: 40px;
      padding: 25px;
      margin: 0 3px;
      box-shadow: 0px 0px 0px 10px rgba(240,240,240,1);
      background-size: auto 25px;
    }
    .likeBtn, .dissBtn {
      height: 90px;
      width: 90px;
      padding: 25px;
      margin: 0 6px;
      box-shadow: 0px 0px 0px 10px rgba(240,240,240,1);
      background-size: auto 50px;
    } 
}
              
            
!

JS

              
                import { StacheElement, ObservableArray } from "//unpkg.com/can@pre/core.mjs";

class EvilTinder extends StacheElement {
  static view = `
    <div class="header"></div>
    <div class="result {{# if(this.liking) }}liking{{/ if }}
                       {{# if(this.noping) }}noping{{/ if }}"></div>
    <div class="images">
      <div class="current" style="left: {{ this.howFarWeHaveMoved }}px">
        <img
          alt="Current Profile Image"
          src="{{ this.currentProfile.img }}"
          draggable="false"
        >
      </div>
      <div class="next">
        <img alt="Next Profile Image" src="{{ this.nextProfile.img }}">
      </div>
    </div>

    <div class="footer">
      <button class="dissBtn" on:click="this.nope()">Dislike</button>
      <button class="likeBtn" on:click="this.like()">Like</button>
    </div>
  `;

  static props = {
    profiles: {
      get default() {
        return new ObservableArray([
          { name: "gru", img: "https://user-images.githubusercontent.com/78602/40454685-5cab196e-5eaf-11e8-87ac-4af6792994ed.jpg" },
          { name: "hannibal", img: "https://user-images.githubusercontent.com/78602/40454705-6bf4d3d8-5eaf-11e8-9562-2bd178485527.jpg" },
          { name: "joker", img: "https://user-images.githubusercontent.com/78602/40454830-e71178dc-5eaf-11e8-80ee-efd64911e35f.png" },
          { name: "darth", img: "https://user-images.githubusercontent.com/78602/40454681-59cffdb8-5eaf-11e8-94ac-4849ab08d90c.jpg" },
          { name: "norman", img: "https://user-images.githubusercontent.com/78602/40454709-6fecc536-5eaf-11e8-9eb5-3da39730adc4.jpg" },
          { name: "stapuft", img: "https://user-images.githubusercontent.com/78602/40454711-72b19d78-5eaf-11e8-9732-80155ff8bb52.jpg" },
          { name: "dalek", img: "https://user-images.githubusercontent.com/78602/40454672-566b4984-5eaf-11e8-808d-cb5afd445e89.jpg" },
          { name: "wickedwitch", img: "https://user-images.githubusercontent.com/78602/40454720-7c3d984c-5eaf-11e8-9fa7-f68ddd33e3f0.jpg" },
          { name: "zod", img: "https://user-images.githubusercontent.com/78602/40454722-802ef694-5eaf-11e8-8964-ca648368720d.jpg" },
          { name: "venom", img: "https://user-images.githubusercontent.com/78602/40454716-76bef438-5eaf-11e8-9d29-5002260e96e1.jpg" }
        ]);
      }
    },

    howFarWeHaveMoved: Number,

    emptyProfile: {
      get default() {
        return {
          img: "https://stickwix.com/wp-content/uploads/2016/12/Stop-Sign-NH.jpg"
        };
      }
    },

    get currentProfile() {
      return this.profiles[0] || this.emptyProfile;
    },

    get nextProfile() {
      return this.profiles[1] || this.emptyProfile;
    },

    get liking() {
      return this.howFarWeHaveMoved >= 100;
    },

    get noping() {
      return this.howFarWeHaveMoved <= -100;
    }
  };

  like() {
    console.log("LIKED");
    this.profiles.shift();
  }

  nope() {
    console.log("NOPED");
    this.profiles.shift();
  }

  connected() {
    var current = this.querySelector(".current");
    var startingX;

    this.listenTo(current, "pointerdown", event => {
      startingX = event.clientX;

      this.listenTo(document, "pointermove", event => {
        this.howFarWeHaveMoved = event.clientX - startingX;
      });

      this.listenTo(document, "pointerup", event => {
        this.howFarWeHaveMoved = event.clientX - startingX;

        if (this.liking) {
          this.like();
        } else if (this.noping) {
          this.nope();
        }

        this.howFarWeHaveMoved = 0;
        this.stopListening(document);
      });
    });
  }
}

customElements.define("evil-tinder", EvilTinder);

              
            
!
999px

Console