Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change where something scrolls to based on the current position on the page?
    primarykey
    data
    text
    <p>Sorry if my question is unclear, I had a hard time trying to phrase it properly.</p> <p>I have a series of 100% width gallery-like images with some side arrows on top to navigate through them. I'm having a hard time trying to think of a method that would allow me to change where the arrows scroll to depending on what image is currently on the screen.</p> <p>I basically need something like this:</p> <p>if (element2) is currently taking up 100% of the viewport, have (leftarrow) go to (element1) and have (rightarrow) go to (element3)</p> <p>I've tried to sort of formulate what this would entail, something like:</p> <ol> <li>check if (element2) is taking up 100% of the viewport -- not sure if you can do this</li> <li>if (element2) taking up 100% of the viewport == true, change the href of (leftarrow) to (element1) -- I assume you can do this with some sort of innerHTML thing</li> <li>if (element2) taking up 100% of the viewport == true, change the href of (rightarrow) to (element3)</li> </ol> <p>I'm a little overwhelmed. Can someone point me in the right direction? Or let me know if this method would even work? Any help would be appreciated! :-)</p> <p>edit: updated with some code</p> <p>Here's how I currently have the side arrows to (sort of) function:</p> <pre><code>$('.sidearrowleft').click(function () { $.scrollTo('#img1', 800); }); $('.sidearrowright').click(function () { $.scrollTo('#img2', 800); }); </code></pre> <p>I'm using the <a href="https://github.com/flesler/jquery.scrollTo" rel="nofollow">scrollTO</a> plugin from Ariel Flesler to go to my div containing the image.</p> <p>So right now it functions correctly for just two images, but I need some way of setting a value to the arrows depending on what image the window is currently on so I can have it function for more than just two images, if that's clear.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload