Questions tagged [js-scrollintoview]

The Element.scrollIntoView() method scrolls the current element into the visible area of the browser window.

Syntax

element.scrollIntoView(); // Equivalent to element.scrollIntoView(true)
element.scrollIntoView(alignToTop); // Boolean arguments
element.scrollIntoView(scrollIntoViewOptions); // Object argument

MDN

https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

Can I use?

desktop

mobile

A good answer on SO

Demo

https://jsbin.com/cuweho

162 questions
3
votes
0 answers

Scroll into view to clicked accordion item

I'm making a Russian language dictionary in which entries for keywords are inserted into accordion elements. The information inside the accordion is taken from a PHPmyadmin database. So far so good: I managed to set the database and the accordion…
swrutra
  • 177
  • 6
3
votes
0 answers

Does scrollIntoView scroll to hidden DIV's even when scroll bars have been turned off (i.e overflow:hidden)?

I'm currently working on implementing scrollIntoView in a test tool. I noticed that element.scrollIntoView() scrolls to hidden elements (DIV's) even when the overflow of their containers is hidden (scroll bars turned off). Is this behavior of…
3
votes
1 answer

scrollIntoView() bugging on Chrome

I am trying to achieve the effect where I can scroll jump from one to another div ID. Basically I scroll down on div-1 and triggers an event on the scroll and jumps to div-2 and vice versa. I was able to achieve it in vanilla JS. It's flickering on…
3
votes
1 answer

How to get element.scrollintoview to work while under a position:fixed footer

Is there any way to detect that the user has focused on an input that is under the fixed footer? I have a form that allows the user to enter multiple items and keep adding items. They normally are able to tab into the input boxes and the screen…
Jolley71717
  • 678
  • 1
  • 8
  • 20
2
votes
1 answer

What does it mean for a CSS element edge to be "outside" a scrolling box's edge?

What is the proper way to interpret the following specification? "If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B, do…
Arial
  • 326
  • 2
  • 11
2
votes
1 answer

Is there a way to calculate how long it will take for a smooth scroll to end

I want my animation to run after the screen has stopped scrolling in Javascript, otherwise the user won't be able to see it. Unfortunately, the speed of scrolling in chrome can vary a lot, and I don't know how to calculate the speed.
2
votes
1 answer

Element Out Of The ScreenShot error while taking screenshot from whatsapp using selenium and VBA

I need somebody to help with selenium classes to bring the information about message read/receipt to the excel sheet. From the help in my previous question, I have got somewhere. But I need more help for going further. I send message from excel…
2
votes
1 answer

Element.scrollIntoView(); Not working in Chrome and Edge, Works in Firefox?

Let me preface by saying I am relatively green in respect to JavaScript. However, I am trying to create a JavaScript function that will listen for a wheel event, determine the direction of the scroll and scroll the next part of the page into view.…
2
votes
1 answer

How to set a timed transition to the .scrollIntoView behavior: smooth?

This is my code: document.querySelector(#theId).scrollIntoView({ behavior: "smooth", }); I have gone to the documentation of scrollIntoView and I don't seem to find a way to set the speed of the smooth transition. I would ideally like…
assensi
  • 352
  • 1
  • 6
  • 17
2
votes
1 answer

How do I fallback from scrollIntoViewOptions for compatibility with Safari?

I have an onclick that triggers this function: function thread2M() { var elmnt = document.getElementById("scroll2"); elmnt.scrollIntoView({behavior: "smooth", block: "center", inline: "center"}); } which scrolls the page to a…
2
votes
1 answer

How can I execute a "scrollIntoView()" function if the headless of the webdriver is equals to True?

I'm trying to execute a code that scrolls down an inner div to a certain element. That just works if: Options().headless = False But as you guys know, that isn't good to the performance of the whole thing. The code that do the scroll is: element =…
2
votes
1 answer

scrollIntoView not working properly with lazy image load

I am having trouble getting scrollIntoView API working correctly when there are lazy image load on the page. Essentially, when the page loads, I grab the element via querySelector and when it scrolls, the focus is off due to the image loading (it…
Alejandro
  • 2,266
  • 6
  • 35
  • 63
2
votes
1 answer

scrollIntoView() not working on IOS safari and chrome?

I'm super new to javascript and programming in general, and am attempting to use the scrollIntoView() function to no avail. I tested the below code in mobile Android Chrome and Samsung Internet and it works fine, but in mobile IOS Chrome and Safari…
Dom
  • 21
  • 1
  • 4
2
votes
1 answer

How to check if an element is into view using Selenium WebDriver?

I have to check if an element is in view and if not, only then scroll it into view using following and then interact with it - ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", element); If an element is in view, don't…
Alpha
  • 13,320
  • 27
  • 96
  • 163
2
votes
1 answer

Calling scrollIntoView(...) with block center not working

I'm trying to get the following code to work but it doesn't: $.each($("input, select"), function (index, input) { input.addEventListener("invalid", function () { this.scrollIntoView({ behavior: 'smooth', …
gib65
  • 1,709
  • 3
  • 24
  • 58
1 2
3
10 11