pass the search result to scrollIntoView
See original GitHub issueI am keen to pass the search result (if find any) to the scrollIntoView function in jQuery.
I use the code below for the search:
$input.on("input", function () {
var searchVal = this.value;
$content.unmark({
done: function () {
$content.mark(searchVal, {
"wildcards": "disabled",
"accuracy": "exactly",
"iframes": true,
"ignoreJoiners": false,
"acrossElements": true,
"separateWordSearch": false,
done: function () {
$results = $content.find("mark");
currentIndex = 0;
jumpTo();
}
});
}
});
});
here the function jumpTo() is defined as
function jumpTo() {
if ($results.length) {
var position,
$current = $results.eq(currentIndex);
$results.removeClass(currentClass);
if ($current.length) {
$results.scrollIntoView({
block: 'center',
inline: 'center'
});
}
}
}
but it does not work and instead gives me the error below:
19:1380 Uncaught TypeError: $results.scrollIntoView is not a function
I further require the search scrolls to elements one by one if there are more than one results.
Please can you help?
Than you very much for your time.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
scrollIntoView Scrolls just too far - Stack Overflow
The issue is that it goes just a tad too far. Like the option they are on is about 10px too high. So,...
Read more >How to Scroll into view in Selenium Webdriver
It was a little challenging to scroll for each element. In Selenium we can do this with scrollIntoView(true) which can scroll automatically till ......
Read more >Element.scrollIntoView() - Web APIs | MDN
The Element interface's scrollIntoView() method scrolls the element's ancestor containers such that the element on which scrollIntoView() is ...
Read more >scrollIntoView - Cypress Documentation
scrollIntoView () can time out waiting for assertions you've added to pass. Command Log. Assert element is visible after scrolling it into view....
Read more >Scrolling a React Element into View | Building SPAs
This method will scroll the element's parent container so that it becomes visible to a user. Nice! Using scrollIntoView in React. How do...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try this - https://jsfiddle.net/Mottie/9k84baqf/
That demo had some weird quirks; but the main point is that
scrollIntoView
requires a DOM element, not a jQuery element.Hi @julmot. Please can kindly you take a look at this ticket?