Learn when to use e.preventDefault() and when to avoid it. In this lesson you learn how to add an object that contains all of the rules for the flash-card game, and later the solitaire game. This object will be used to build out the discard piles and aler
- [Instructor] Next, we're going to add drag and drop functions…to our cards.…So let's start by building out our discard pile targets.…The discard pile will have two divs.…And, similar to our card,…we'll need to use absolute positioning.…As a quick review of absolute positioning,…remember, unless it has a parent that is set to relative,…the containing div will float out…to the next nearest relative item,…which might be the top left of the screen…and we don't want that.…The good news is, the CSS is already written for you.…I just want to make sure you understand how it works.…
We're going to first add some rules to our game…that will tell us how many discard piles we need.…In a flashcard game, we're really only going to need…just the one.…But in a game like solitaire, you'll need two rows.…One of four and one of seven.…So, let's account for multiple rows…and create the discard row as an array.…Under our games object we'll create some rules.…And let's attach it to the game.…So this.rules, and that's going to be set to an object.…
- Working with prototype and dynamic elements
- Using bind, call, and apply
- Using the Fisher–Yates formula
- When to use e.preventDefault() and when to avoid it
- Drag-and-drop life cycle
- Using prototypical inheritance to optimize your code
Skill Level Intermediate
Q: This course was updated on 1/16/2019. What changed?
A: The following topics were updated: propagation and drag and drop.