Get Scroll and keys to work.
-
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.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Get Scroll and keys to work.’ is closed to new replies.