Skip to content

Added an optional options argument to the card component for situations where clicking a card to flip is not desired.#39

Open
luk- wants to merge 2 commits into
visionmedia:masterfrom
luk-:master
Open

Added an optional options argument to the card component for situations where clicking a card to flip is not desired.#39
luk- wants to merge 2 commits into
visionmedia:masterfrom
luk-:master

Conversation

@luk-

@luk- luk- commented Mar 10, 2012

Copy link
Copy Markdown

While using the card component in a project, I realized that there are situations where I don't want clicking the card to run flip() on it (for example, when putting a draggable map on top of a card I would constantly be flipping the card).

I noticed that the options argument in Card.prototype.render did not appear to be currently utilized, so I added a third optional argument when creating cards which is eventually passed to this function.

var card = ui.card('<p>Front</p>', '<p>Back</p>', {self_flip: false});

If the third argument is not included when a card is defined, the card will default to self_flip: true. I thought this was a good way to approach this in order to allow options to contain other single card-specific configuration settings should more come up in the future. Let me know your thoughts.

@tj

tj commented Mar 10, 2012

Copy link
Copy Markdown
Member

we could remove that default all together and just force the dev to decide how flipping is done

@luk-

luk- commented Mar 10, 2012

Copy link
Copy Markdown
Author

I actually like that idea even more

@tj

tj commented Mar 10, 2012

Copy link
Copy Markdown
Member

the use-case for having it auto-flippable is probably pretty slim haha. the doc one can still do that to demonstrate the API I guess

@luk-

luk- commented Mar 10, 2012

Copy link
Copy Markdown
Author

Were you thinking of removing self.flip() from Card.prototype.render completely and leaving it up to the dev to handle flip() in his/her own code?

@luk-

luk- commented Mar 10, 2012

Copy link
Copy Markdown
Author

The other thing with passing an options object as a third argument, it could be used to specify the flip direction, speed, etc. Lots of good optional info could be passed through this for when a dev wants to mix it up a bit.

@tj

tj commented Mar 11, 2012

Copy link
Copy Markdown
Member

premature for now since we dont have those, plus I like specifying those things via unique methods vs shoving large objects as an API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants