Skip to content

Instantly share code, notes, and snippets.

@jecfish
Last active August 31, 2017 16:14
Show Gist options
  • Save jecfish/fbb98b368557f96bfc9c24505fa27c7c to your computer and use it in GitHub Desktop.
Save jecfish/fbb98b368557f96bfc9c24505fa27c7c to your computer and use it in GitHub Desktop.
// index.ts
import { Element as PolymerElement } from '@polymer/polymer/polymer-element';
import '@polymer/polymer/lib/elements/dom-repeat';
import { GestureEventListeners } from '@polymer/polymer/lib/mixins/gesture-event-listeners';
import * as view from './cards.template.html';
export class MyCards extends GestureEventListeners(PolymerElement) {
static get template() {
return view;
}
constructor() {
super();
}
static get properties() {
return {
cards: Array
};
}
getClass(item) {
return (item.isFlipped || item.isMatched) ? 'card flipped' : 'card';
}
cards: PolyTest.Card[];
private get isReachMaxFlippedCard() {
// logic to check max 2 cards flip at any point of time
}
private get isAllCardsMatched() {
// logic to check if all cards matched
}
private isMatch([image1, image2]: string[]) {
// logic to check if two card images matched
}
flip({ model }) {
const card = { ...model.item };
const index = model.index;
// logic to flip the card
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment