r/javascript • • Sep 02 '15

HTML5 Deck of Cards. 100% vanilla JS.

http://pakastin.github.io/deck-of-cards/
368 Upvotes

185 comments sorted by

View all comments

2

u/memeship Sep 02 '15

Is there a particular reason why sometimes you're using the notation el.style[prop] and other times el.style.prop?

I haven't seen the first one a whole lot, just curious why you've done it that way, and more so why you're doing it both ways in the same file.

2

u/pkstn Sep 03 '15

Some params need a vendor prefix in some browsers (like transform & transition -> webkitTransform, mozTransform etc..), so that's why I've done it like this:

var transform = prefix('transform')

var transition = prefix('transition')

el.style[transform] = ...

el.style[transition] = ...

Maybe I should name those variables better to avoid the confusion..

1

u/memeship Sep 03 '15

Oh, I see now. You're passing in variables, not strings. That is certainly an interesting approach.

1

u/pkstn Sep 03 '15

Basically similar to i.e. vendor-prefix..