Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PAID] jQuery help – change element style when bottom viewport hits element
#21
(03-05-2013, 09:08 PM)brad-t Wrote: Will try it when I have some time – thank you!!

No Problem Smile

(03-05-2013, 09:08 PM)Euan T. Wrote: You could do, yes. But it's easier to just use the built in methods which do exactly that behind the scenes.

Very true. I was thinking more of the lines of code readability. However, what you did looks fine as well, just maybe not in a "it does this exactly" sort of way. Once again, thanks for the corrections.
#22
Just hope it works now Wink I just edited my above post with a version using (document).ready() as it makes the code slightly neater. It's the version I'd personally prefer if it works.
#23
(03-05-2013, 09:14 PM)Euan T. Wrote: Just hope it works now Wink I just edited my above post with a version using (document).ready() as it makes the code slightly neater. It's the version I'd personally prefer if it works.

Yeah, I agree. It makes it look a lot neater. Like I said, I'm not a huge fan of javascript, so when I saw the (document).ready(), it made me cringe a bit.
#24
Still not working for me. None of this. Sincerely starting to wonder if there's some weird conflict or something preventing this from working.
#25
Any chance I can get a temp account to take a look and play in the console?
#26
sure, will PM you details
#27
Finally got this working, so I'll share the code that ended up working:

jQuery.noConflict();

jQuery(window).scroll(function() {
	var myElt        = jQuery('#hidecontrol'); // whatever element you want to check
	var thewindow    = jQuery(window); // the window jQuery element
	var myTop        = myElt.offset().top; // the top (y) location of your element
	var windowTop    = thewindow.scrollTop(); // the top of the window
	var windowBottom = windowTop + thewindow.height(); // the bottom of the window

	if ((myTop > windowTop && myTop < windowBottom)) {
	    jQuery('#control_menu').fadeOut(); // Fade out the element because the element we're checking is in view
	} else {
	    jQuery('#control_menu').fadeIn(); // Fade the element back in
	}
});
#28
I really hope someone else will find this useful. Thanks so much!!


Forum Jump:


Users browsing this thread: 1 Guest(s)