Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PAID] jQuery help – change element style when bottom viewport hits element
#11
Brad, maybe this code would do it - basically you have two divs;

http://stackoverflow.com/questions/67447...down-200px

http://jsfiddle.net/KEjfe/4/

The > would need to become < so that the footer vanished after the page scrolled instead of appearing.
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


#12
(02-17-2013, 08:11 AM)Leefish Wrote: Brad, maybe this code would do it - basically you have two divs;

http://stackoverflow.com/questions/67447...down-200px

http://jsfiddle.net/KEjfe/4/

The > would need to become < so that the footer vanished after the page scrolled instead of appearing.

Yes, this would work. You could dynamically get the required height by using jQuery to get the vertical offset of the #posts element.
#13
I'm so confused ... haha. Will try it. Thanks.
#14
Literally willing to pay someone just to do this, I honestly don't want to invest more time into learning jQuery just to solve this as I have a lot of other things to do on the site. PM me if you're interested.
#15
TAKE MY MONEY
#16
Don't worry about the money... Unless you insist... This is all based on if I can get this right.

Download, Upload and Link:

http://www.appelsiini.net/projects/viewport

then use

(function() {
    $(window).bind("scroll", function(event) {
        if($("#PUTYOURIDHERE:in-viewport").length > 0)
        {
            $("#SECONDID").css("display", "true");
        }
        else {
            $("#SECONDID").css("display", "none");
        }  
    });
});

sorry if this doesn't work. It's untested.
#17
(03-05-2013, 08:26 PM)Init Wrote: Don't worry about the money... Unless you insist... This is all based on if I can get this right.

Download, Upload and Link:

http://www.appelsiini.net/projects/viewport

then use

(function() {
    $(window).bind("scroll", function(event) {
        if($("#PUTYOURIDHERE:in-viewport").length > 0)
        {
            $("#SECONDID").css("display", "true");
        }
        else {
            $("#SECONDID").css("display", "none");
        }  
    });
});

sorry if this doesn't work. It's untested.

Only possible issue I can see is that "display: true" is not valid CSS. Try this:

jQuery.noConflict();
(function() {
    jQuery(window).on('scroll', function(event) {
        if(jQuery("#PUTYOURIDHERE:in-viewport").length > 0)
        {
            jQuery("#SECONDID").show();
        }
        else {
            jQuery("#SECONDID").hide();
        }  
    });
});

Also note I replaced .bind() with .on() as .bind() has been deprecated since jQuery 1.7.

Again, also untested as above.

EDIT:

Or try this version, using (document).ready(). Unsure if the JS plugin will even work with that, but it makes the code slightly neater:

jQuery.noConflict();
jQuery(document).ready(function($) {
    $(window).on('scroll', function(event) {
        if ($("#PUTYOURIDHERE:in-viewport")) {
            $("#SECONDID").show();
        } else {
            $("#SECONDID").hide();
        }
    });
});
#18
(03-05-2013, 09:03 PM)Euan T. Wrote:
(03-05-2013, 08:26 PM)Init Wrote: Don't worry about the money... Unless you insist... This is all based on if I can get this right.

Download, Upload and Link:

http://www.appelsiini.net/projects/viewport

then use

(function() {
    $(window).bind("scroll", function(event) {
        if($("#PUTYOURIDHERE:in-viewport").length > 0)
        {
            $("#SECONDID").css("display", "true");
        }
        else {
            $("#SECONDID").css("display", "none");
        }  
    });
});

sorry if this doesn't work. It's untested.

Only possible issue I can see is that "display: true" is not valid CSS. Try this:

jQuery.noConflict();
(function() {
    jQuery(window).on('scroll', function(event) {
        if(jQuery("#PUTYOURIDHERE:in-viewport").length > 0)
        {
            jQuery("#SECONDID").show();
        }
        else {
            jQuery("#SECONDID").hide()
        }  
    });
});

Also note I replaced .bind() with .on() as .bind() has been deprecated since jQuery 1.7.

Again, also untested as above.

Oh, well that's embarrassing. See, this is what happens when a programmer in "Programmer Mode" uses CSS :/ JK

Thanks for fixing it. I'm not much of a javascript person myself. Although, I do know a bit.

However, instead of using .show and .hide, can you not instead use display: block or display:inline


jQuery.noConflict();
(function() {
    jQuery(window).on('scroll', function(event) {
        if(jQuery("#PUTYOURIDHERE:in-viewport").length > 0)
        {
            $("#SECONDID").css("display", "block");
        }
        else {
            $("#SECONDID").css("display", "none");
        }  
    });
});

#19
Will try it when I have some time – thank you!!
#20
You could do, yes. But it's easier to just use the built in methods which do exactly that behind the scenes.


Forum Jump:


Users browsing this thread: 1 Guest(s)