• Resolved tv3master

    (@tv3master)


    Hi, i am using the plugin to scroll to an image slider, where i want the bottom off the slider to align with the bottom off the browser.
    Is there any way i can set the ofsset from the bottom?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author malihu

    (@malihu)

    Hi,

    It is not possible to offset page scrolling from the bottom of the viewport (at least not via plugin’s options).

    The only way to do what you describe is via javascript. Can you add custom js code to your theme? If yes, let me know (I’ll provide a code sample which you can use with your elements).

    Thread Starter tv3master

    (@tv3master)

    Hi

    I am new to wordpres so i have no idea whether i can.
    Is it as simple as adding it in the text view in the page editor?
    If no, how can I check I can add custom javascript?
    or even enable it by installing a plugin?

    And thanks for the fast response!

    Plugin Author malihu

    (@malihu)

    Post/page editor does not accept javascript code.

    You should first check if your theme provides an option to insert custom js (this is usually via some text field under a theme option). If such option exist, you should use it.

    Another way would be via some plugin, e.g.
    https://ww.wp.xz.cn/plugins/custom-css-js/

    Lastly, you can add the code manually in your theme’s template. The problem with this is that the custom code will be removed if/when you update the theme (just the theme, updating WordPress won’t remove it). To avoid this, you’ll need to create a child-theme.
    To add it manually, go to ‘Appearance’: ‘Editor’ and click to edit ‘Footer (footer.php)’ under templates. Find the line with: <?php wp_footer(); ?> and add the custom js script below it inside a script tag (<script>...the js code below goes here...</script>). Click ‘Update File’ to save it.

    So, the code below is the one to use. Note that you should change the #section-2 value to the id value you used (i.e. your image slider id):

    
    (function($){
      $(window).on("load resize",function(){
        var val="#section-2"; //set your element's id/hash fragment value
        $("a[href*='"+val+"']").data("ps2id-offset",function(){
          return $(window).height()-$(val).height();
        });
      });
    })(jQuery);
    

    Let me know πŸ™‚

    • This reply was modified 9 years, 4 months ago by malihu.
    Thread Starter tv3master

    (@tv3master)

    I tried adding the code via my child theme in foother.php, directly in my parent theme and with the plugin. all failed and made the page scroll to the bottom when it loaded, or when I scrolled up and clicked the link again.

    I did forgot to note these things however:

    for testing purposes I added a target id shortcode, and also to make sure there was not a problem with using my slider id.

    the scroll link is in the form of a # code (#scroll is what I am using) in the link linking to the page (so like this: index.php/link_to_page/#scroll)

    and finally: I have a header that becomes smaller and has a fixed position as I scroll down the page.

    Please don’t waste to much of your time helping me with this one, it is not a big problem if I don’t get it to work πŸ˜‰

    Plugin Author malihu

    (@malihu)

    If your link is like index.php/link_to_page/#scroll, then you should change:
    var val="#section-2";
    to:
    var val="#scroll";
    in the script code.

    Can you post a link of your site/page? I’d probably be able to help solve the issue if I could visit your url.

    • This reply was modified 9 years, 4 months ago by malihu.
    • This reply was modified 9 years, 4 months ago by malihu.
    Thread Starter tv3master

    (@tv3master)

    Yeah I know, i did that πŸ˜‰

    Is there a way I can send it in private? Since it is for a school project I don’t really like to have a visit from the whole internet on my website. The server is also quite slow so it doesn’t really help if other people are checking out the site aswell :s

    Plugin Author malihu

    (@malihu)

    Sure, contact me πŸ™‚

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Offset from bottom’ is closed to new replies.