-
Notifications
You must be signed in to change notification settings - Fork 0
Active search result sticks to bottom and top of page #330
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
|
@chasenlehara this PR has been updated to address your last comment. |
…into 276-active-result-sticks-to-bottom
static/search.js
Outdated
| if(isMovingDown){ | ||
| var resultsContainerHeight = this.$resultsContainer.height(); | ||
|
|
||
| var isBellow = activeResultPosTop > resultsContainerHeight; |
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.
isBelow?
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.
Overall looks good. Check out my comments for a couple small things. A medium-sized thing to consider is that this method has 2 jobs: toggling the class and adjusting the scroll. There isn't a ton of code so maybe it doesn't matter that much, but personally I'd break them apart.
static/search.js
Outdated
| // sets property and adds class to active result | ||
| activateResult: function($result){ | ||
| // Get position top of last active element | ||
| var lastResultPosTop = parseInt(this.$activeResult && this.$activeResult.position().top || 0); |
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.
props on IDing this bug ahead of time!
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.
Make sure to always pass 10 as the second argument to parseInt (you can search for reasons why).
static/search.js
Outdated
| var isAbove = activeResultPosTop < 0; | ||
|
|
||
| if(isMovingDown){ | ||
| if(isBellow){ |
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.
isMovingDown && isBelow could be on one line
static/search.js
Outdated
| this.resetScrollToBottom(activeResultPosTop, resultsContainerHeight); | ||
| } | ||
| }else{ | ||
| if(isAbove){ |
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.
could use an else if(isAbove)
static/search.js
Outdated
|
|
||
| if(isMovingDown){ | ||
| if(isBellow){ | ||
| this.resetScrollToBottom(activeResultPosTop, resultsContainerHeight); |
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.
Much more readable! Awesome 💃
| var resultsContainerHeight = this.$resultsContainer.height(); | ||
|
|
||
| this.$resultsContainer.scrollTop(this.$activeResult.position().top - activeResultOffset); | ||
| var isMovingDown = lastResultPosTop < this.$activeResult.position().top; |
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.
Add a comment here to clarify that you are talking about the arrow key direction
static/search.js
Outdated
|
|
||
| this.$resultsContainer.scrollTop(this.$activeResult.position().top - activeResultOffset); | ||
| var isMovingDown = lastResultPosTop < this.$activeResult.position().top; | ||
| var isBellow = activeResultPosTop > resultsContainerHeight; |
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.
isBelow
|
@bgando I agree with your reasoning behind splitting up |
|
@chasenlehara do you want it to stop when it reached the bottom or top? Currently, it restarts from the other end. |
|
I personally don’t like that it goes back to the top when you reach the bottom, but I’m willing to see how people react to it in practice. |
chasenlehara
left a comment
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.
Looks great! I added a comment for one minor thing.
static/search.js
Outdated
| // sets property and adds class to active result | ||
| activateResult: function($result){ | ||
| // Get position top of last active element | ||
| var lastResultPosTop = parseInt(this.$activeResult && this.$activeResult.position().top || 0); |
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.
Make sure to always pass 10 as the second argument to parseInt (you can search for reasons why).


Uh oh!
There was an error while loading. Please reload this page.