Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorter clearer code (35% smaller file), and support for passing random in data-color and data-angle #1

Merged
merged 5 commits into from Aug 28, 2013

Conversation

TalAter
Copy link
Contributor

@TalAter TalAter commented Aug 14, 2013

Great plugin, I've learned a lot from the tricks you've used here.
Still, I couldn't help myself from refactoring the switch case statement.
The result is smaller, slightly faster, while still (I believe) not sacrificing code readability.

Changes:

  • Refactored the switch on angle statement to remove all the repeating code that is the same for all angles, leaving only the difference between the angles inside the switch. This change lowered the filesize from 8.1 kb to 5.3 kb. The only code change here (beside moving lines and deleting the repeating ones), is the addition of the iLimit variable which holds either the width or the height.
  • Refactored if blocks that define angle, and shadow color so they are shorter, clearer, and also support passing random as the element's color or angle data-attribute.

@peachananr
Copy link
Owner

Thanks @TalAter . Will take a look. :)

@TalAter
Copy link
Contributor Author

TalAter commented Aug 27, 2013

Let me know if you need an explanation.

The git diff really makes it look complicated... But the only change I did in the refactor is to move all the repeating code outside the switch, leaving only the code that is different in there. The only thing I added is the iLimit variable which holds either the width or height so that the lines that use either one can be taken out of the switch.

peachananr added a commit that referenced this pull request Aug 28, 2013
Shorter clearer code (35% smaller file), and support for passing random in data-color and data-angle
@peachananr peachananr merged commit 35e263b into peachananr:master Aug 28, 2013
@TalAter TalAter deleted the codediet branch August 28, 2013 16:06
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.

None yet

2 participants