gre/slider.js — pull request #17 by mpdaugherty (2012-07-19 03:12:57+00:00)
Title: Give options in the constructor (#14)

This pull request addresses issue #14 (All options could be given in the constructor). This is my first time working with Coffee Script, so I thought it would be a fun simple issue to take care of. Would love some feedback.

The interesting part is the constructor of slider (https://github.com/mpdaugherty/slider.js/pull/new/master#L5R239). I've moved the properties that people may want to set into a 'defaults' object on the prototype. Then, during initialization, if the user passes in an object with any of the same property names, those properties are set directly on the new Slider.

If the setX() functions were all extremely simple (e.g. set property and return `this`), we could also automatically generate them from the default property object. However, they seem to do extra work when @node is already set, so I decided not to go that far.

There are also some other properties like 'transition' that we could probably add to this set of options, and we might want to add the new properties in SliderWithCanvas. I'd like to get your feedback first, however, to make sure these changes match your project; as I mentioned, I haven't done any Coffee Script before, so I'm not really sure if this is idiomatic or not...

To test, I modified demo/index.html to use the new constructor options (https://github.com/mpdaugherty/slider.js/pull/new/master#L1R109). Is there a more complete test suite somewhere?

Finally, my editor automatically removed extra spaces at the end of some lines, so the diff is a little messy. My apologies.