0

I have a slide show of captions that move on side arrow clicks, and I need to change an image in the page once certain captions (labeled by individual ID's) hit position().left === 0.

I am able to get their location through .position().left, but that only happens upon load. How can I get the program to always listen for location? scrollLeft() doesn't work due to the nature of the scrolling settings and an interval does not give me the precision I want.

if ((($('#captionthree').position()).left) === 0) {
                //removes initial image
                $("img").remove('#imgone');
                //appends the new image
                $('#imagecontainer').append('<img id="imgtwo">');

            }

I'm doing this on top of fullpage.js, if that paints a better picture.
Any help is appreciated!!

Joolian
  • 71
  • 5
  • 1
    this might help: http://stackoverflow.com/questions/6170417/how-do-i-listen-to-whenever-a-div-changes-position-with-jquery – DCR Feb 22 '17 at 23:41
  • If you are using fullPage.js (as per your tags), then you should be using the libary's callbacks such as `onLeave` or `onSlideLeave` or even `afterLoad` or `afterSlideLoads`. Examples [in the docs](https://github.com/alvarotrigo/fullPage.js#callbacks). – Alvaro Feb 23 '17 at 15:57

0 Answers0