OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Find first scrollable parent

  • Thread starter Thread starter Jeanluca Scaljeri
  • Start date Start date
J

Jeanluca Scaljeri

Guest
I have this situation in which I need to scroll an element into the viewport. The problem is that I don't know which element is scrollable. For example, in Portrait the body is scrollable and in Landscape its an other element (and there are more situation which change the scrollable element)

Now the question, given an element which needs to be scrolled into the viewport, what is the best way to find its first scrollable parent ?

I've setup a demo here. With the button you can toggle between two different situations

Code:
<div class="outer">
    <div class="inner">
        <div class="content"> 
            ...
            <span>Scroll me into view</span>
        </div>
    </div>
</div>

The body is scrollable or .outer

Any suggestions ?
<p>I have this situation in which I need to scroll an element into the viewport. The problem is that I don't know which element is scrollable. For example, in Portrait the body is scrollable and in Landscape its an other element (and there are more situation which change the scrollable element)</p>

<p>Now the question, given an element which needs to be scrolled into the viewport, what is the best way to find its first scrollable parent ?</p>

<p>I've setup a demo <a href="https://jsfiddle.net/pjzj9twe/" rel="noreferrer">here</a>. With the button you can toggle between two different situations</p>

<pre><code><div class="outer">
<div class="inner">
<div class="content">
...
<span>Scroll me into view</span>
</div>
</div>
</div>
</code></pre>

<p>The body is scrollable or <code>.outer</code></p>

<p>Any suggestions ?</p>
Continue reading...
 

Latest posts

Z
Replies
0
Views
1
zuegelwagen
Z
Top