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

Added the ability to customize the result container instead of appending directly to the body. #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

iamkirkbater
Copy link

This specifically works for me in a situation where I have a fixed header, but I realized that sometimes people scroll while the results are still visible. This means that the results end up staying positioned absolutely in the page, while the search bar moves around because it's fixed. So, I added in the ability to add a "container" option where you pass a selector in and the results are then appended there instead of the body. Default functionality still applies if you don't add any selections. I've also added another class if you do define the result set, so that you can add CSS to remove the position absolute if you need to.

var rect = that.getBoundingClientRect();
that.sc.style.left = Math.round(rect.left + (window.pageXOffset || document.documentElement.scrollLeft) + o.offsetLeft) + 'px';
that.sc.style.top = Math.round(rect.bottom + (window.pageYOffset || document.documentElement.scrollTop) + o.offsetTop) + 'px';
that.sc.style.width = Math.round(rect.right - rect.left) + 'px'; // outerWidth

Choose a reason for hiding this comment

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

I think it's still beneficial to set width when using a non-body container.

@markammay
Copy link

Can we merge this PR if/when any issues are resolved? Being able to set your own container if you want, is useful and it would be great to have it in

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