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

Improved code readability #4

Merged
merged 4 commits into from
Mar 22, 2017
Merged

Improved code readability #4

merged 4 commits into from
Mar 22, 2017

Conversation

clintonyeb
Copy link
Contributor

Am a beginner and found your code a great place to learn. Please see my changes and give me a feedback. You are also welcome to merge them 😃 . Thank you

Copy link
Owner

@hsnaydd hsnaydd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @clintonyeb, thank you for pull request. I reviwed your changes and I wrote a few comments. After remove this changes I can merge your pull request.

Thank you for support

src/moveTo.js Outdated
@@ -8,7 +8,7 @@ const MoveTo = (() => {
tolerance: 0,
duration: 800,
easing: 'easeOutQuart',
callback: function() {},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an eslint rule called the comma-dangle. This should not be erased.

src/moveTo.js Outdated
t /= d;
t--;
return -c * (t * t * t * t - 1) + b;
function easeOutQuart(currentTime, startValue, change, duration) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not necessary, the parameters are already explained above and Easing equations is usually known in this way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDoc need to update, if these changes will take, but really got better, I would have left.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

src/moveTo.js Outdated
@@ -121,7 +121,7 @@ const MoveTo = (() => {
* @param {object} options Custom options
*/
MoveTo.prototype.move = function(target, options = {}) {
if (target !== 0 && !target) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target !== 0 should not be deleted here, otherwise if target is 0 the scroll animation will not work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 is falsy in JavaScript. So you need not check that if you are checking for !target.

All these evaluate to false.
if (false), if (null), if (undefined), if (0), if (NaN), if (''), if (""), if (document.all) [1]

Copy link
Owner

@hsnaydd hsnaydd Mar 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes as you said 0 is falsy. If we do it the way you do, move function will return without work

// when target 0 
if (!0) {
  // will return 
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I get it now!

@hsnaydd hsnaydd merged commit 57c06b5 into hsnaydd:master Mar 22, 2017
@clintonyeb
Copy link
Contributor Author

Wow, first successful pull request 😃 ! Thanks.

@hsnaydd
Copy link
Owner

hsnaydd commented Mar 22, 2017

Thank you @clintonyeb, I hope you will do more 🎉

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.

3 participants