• Hi, thanks for this plugin, and what it have done so far 🙂

    I have tried for days to implant scroll-to-id for keys and for scrolls, so you can’t end up in between pages at all.
    I have found your earlier responses to these questions but cant get it to work!

      I use this script for the scroll event:
    (function($){
    $(window).load(function(){
    
    /* bind mousewheel event on document */
    $(document).mousewheel(function(e){
        e.preventDefault();
        var section=$("#content > section"), /* define your sections selector (change to your selector) */
            currentTarget=$(".mPS2id-target"), /* define the current section */
        /*
        if mouse-wheel delta is less than zero scroll-to next section from current
        if mouse-wheel delta is greater than zero scroll-to previous section from current
        */
        to=e.deltaY<0 ? currentTarget.next().attr("id") : currentTarget.prev().attr("id");
        /* if variable to is defined, use plugin's scrollTo method to programmatically scroll to target */
        if(to){
            $.mPageScroll2id("scrollTo",to);
        }
    });
    
    });
    })(jQuery);
      And this for the keys:
    (function($) {
            $(“body”).bind(“keydown keyup”,function(e){
                //prevent arrows default behaviour on keydown//
                if(e.type===”keydown”){ e.preventDefault(); }
                //scroll to next/prev sections on keyup (down arrow code is 40, up arrow code is 38)//
                if(e.type===”keyup” && (e.keyCode===40 || e.keyCode===38)){
                    //get current section//
                    var current=$(“.mPS2id-target”),
                        //get the id of previous and next sections in an array//
                        siblings=[current.prev("._mPS2id-t").attr("id"),current.next("._mPS2id-t").attr("id")],
                        //scroll  toprevious or next section according to key code
                        to=e.keyCode===38 ? siblings[0] : siblings[1];
                    //do the actual scrolling using plugin’s scrollTo method//
                    $.mPageScroll2id(“scrollTo”,to);
                }
            });
        })(jQuery);

    None of them seams to work.

    I have a three page site, built on three fullscreen (100% x 100%) iFrames.

    https://wordpress.org/plugins/page-scroll-to-id/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello, the plug-in works great.

    But I have a small question. How can I turn off script on different pages per site ID

    Plugin Author malihu

    (@malihu)

    @jaja301000

    If you want to remove the plugin scripts form the front-end, you can add a function like the following one, in your theme’s functions.php:

    add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
    
    function my_deregister_javascript() {
    	if( is_page( 22 ) ){ //remove plugin's scripts on page with id: 22
    		wp_deregister_script( 'page-scroll-to-id-plugin-script' );
    		wp_deregister_script( 'page-scroll-to-id-plugin-init-script' );
    	}
    }

    See more wp conditional tags here: https://codex.wordpress.org/Conditional_Tags

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

The topic ‘Get Scroll and keys to work.’ is closed to new replies.