Skip to content
This repository has been archived by the owner on Dec 29, 2020. It is now read-only.

Give options in the constructor (#14) #17

Closed
wants to merge 7 commits into from

Conversation

mpdaugherty
Copy link

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.

@mpdaugherty
Copy link
Author

P.S. The reason I didn't move node to the options object is in order to prevent breaking existing sites.

@gre
Copy link
Owner

gre commented Jul 19, 2012

I'm currently working on the version 2 of this slider which has already fixed these issues.
Anyway the v2 is not finished and released yet so I could still update the v1 with your changes.

Thanks,
gre

@mpdaugherty
Copy link
Author

No problem. It was a good learning experience anyway. Which tickets relate to v2? Are there any that I could help out with?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants