• Hi, I have one problem with my page. I would like to get effect of auto scrolling down. I mean after page loaded I want to page slowly scroll down to the bottom. It should be only on posts with certain category. Something like you can see in shop’s TV which are used to present some ad. Thank you in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Like the example at https://jsfiddle.net/BjpWB/4/?

    That example uses a click action, but the effect can be triggered by any JS action, such as window.onload. The example is generic and not specific for WP. jQuery needs to be available on the page. You could conditionally output something like the following only when the return of wp_get_post_categories() contains the category in question:

    <script>
    function scrollToAnchor(aid){
        var aTag = jQuery("a[name='"+ aid +"']");
        jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow');
    }
    window.onload = scrollToAnchor('id3');
    </script>
    Thread Starter damians20171

    (@damians20171)

    Thank you. @bcworkz your solution is good. I used another solution which is just to make some button or link on a page which scroll page to specific id on the bottom of page.
    <a href="#id">
    This button or link is clicked automatically after page loaded. I made 2 functions. 1 is just to setTimeout so 2 function can wait 3 secounds to page full load.

    function function1() {
        console.log('Welcome to My Console,');
    }
    
    function1();
    
    setTimeout(function2, 3000);
    
    function function2(){
      
      document.getElementById("id").click();
    
      
    };

    Thanks for help ??

    • This reply was modified 5 years, 2 months ago by damians20171.
    Moderator bcworkz

    (@bcworkz)

    Nice! I’m glad you found something you like. You’re welcome.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Auto scroll’ is closed to new replies.