scroll - Variable not updating in jquery -


  var thumbw = $ ('.whid-thams took'). Width (); Var feedw = $ ('.video-thumbs'). Width (); Var Thambs = Math Floor (feed / thumb); $ ('.' Click on function () {$ (this) .Parent (). (Function () {var scrolls = $ (this) .scrollLeft (); var thumbcount = Math.floor (scrollx / thumbw) ); Var NextScroll = thumbcount + thumbx; var nextthumb = 'li: nth-child (' + nextscroll + ')' hair = $ (this) .fid (next place) .offet () .left; $ (this) .animate ({scrollLeft: childx - 40}, 500, 'linear');});});  

I am creating a side scrolling list of thumbnails, the feed of the thumbnail is the parent of the ".scroll-right" button. When you click ".scroll-right", in the next set, the first step should be to set the scroll value of the feed in the left side of the thumbnail. My problem is that it works for the first, but later the balaks variable does not update. Any ideas how can I do this work?

OK, I understood it

  var childx = $ (This) .Feed (next bar) .offset () Left;  

I was using '.offset ()' instead of 'left'. Position (). Left ', so the childx variable was taking the position of the thumbnail relative to the document rather than its original element So I changed it only to:

  var childx = $ (this) .find (nextthumb) .position (). Left;  

And it worked!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -