• Resolved tistrega

    (@tistrega)


    Hello!

    Thanks for the plugin, for the rich documentation and for the
    fast and great support!

    I have an homepage full width and the floating buttons go over the text in some sections.
    I apply the code that you have recommended to @jamesyesjames and @fjura and it work perfectly for me too!

    Particularly, I insert this to adapt show and fadeout to my homepage:

    jQuery(window).scroll(function () {	 
        var y = jQuery(this).scrollTop();
    	var url= window.location.href;
    	
    	if(y < 1200 || y > 2900) {
            jQuery('.a2a_floating_style.a2a_vertical_style').fadeOut();
        } 
    	else {
            jQuery('.a2a_floating_style.a2a_vertical_style').show();
        }
    });

    However, in this way, the rule is applied to all other pages and post where I have page
    shorter and I set primary content with specific padding left for buttons.

    There is a way to apply this rule only on homepage (or other specific page)?

    I tried a lot of solutions, but none works for me.

    For example, adding an else if
    `else if(window.location.pathname == ‘/contatti’) {
    jQuery(‘.a2a_floating_style.a2a_vertical_style’).show();
    } ` ok in homepage, but it does not work on the specific page (perhaps because I need specific var?),

    or using ( is_page('contatti') ), or ( is_home() ), but sometimes this also creates conflicts with background images and the button disappear on home.

    I’m sorry…I do not know java

    Thanks in advance

    Ro’

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author micropat

    (@micropat)

    Pretty close! It’s best to wrap the whole JavaScript code block in a conditional statement:

    var myCurrentPath = window.location.pathname;
    // If homepage, or another specific page
    if (myCurrentPath === '/' || myCurrentPath === '/another-specific-page/') {
        jQuery(window).scroll(function () {	 
            var y = jQuery(this).scrollTop();
            var url= window.location.href;
            
            if(y < 1200 || y > 2900) {
                jQuery('.a2a_floating_style.a2a_vertical_style').fadeOut();
            } 
            else {
                jQuery('.a2a_floating_style.a2a_vertical_style').show();
            }
        });
    }

    And to prevent the initial display & fade-out when the page loads, add some “Additional CSS” code that applies to your homepage:

    body.home .a2a_floating_style.a2a_vertical_style { display: none; }

    Thread Starter tistrega

    (@tistrega)

    Great! Works perfectly!!!
    Thank you so much for the quick help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Java specific for homepage’ is closed to new replies.