-
Notifications
You must be signed in to change notification settings - Fork 95
Improved code readability #4
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
Conversation
There was a problem hiding this 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() {}, |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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!
Wow, first successful pull request 😃 ! Thanks. |
Thank you @clintonyeb, I hope you will do more 🎉 |
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