2

I'm trying to detect the actual position of my page scrool before start the change orientation.

It will determine what position of my "new" screen (in the new orientation) will be show.

I tried to check, every scroll event, the actual position, as you can see below:

$(window).scroll(function() {       

    var scrollTop = $(window).scrollTop();

    if (scrollTop >= window.secao1 && scrollTop <= window.secao1){
        window.secaoIDSet = "s1";
    }

    if (scrollTop >= window.secao2 && scrollTop <= window.secao2){
        window.secaoIDSet = "s2";
    }

    if (scrollTop >= window.secao3 && scrollTop <= window.secao3){
        window.secaoIDSet = "s3";
    }

    if (scrollTop >= window.secao4 && scrollTop <= window.secao4){
        window.secaoIDSet = "s4";
    }

    if (scrollTop >= window.secao5-2){
        window.secaoIDSet = "s5";
    }       
});

And then I would like to set the position to be show in the new orientation, but I don't know when do this action:

$(window).scrollTop($('#' + window.secaoIDSet).offset().top + 'px');
acg
  • 503
  • 3
  • 11
  • 27
  • Check this out Detect [viewport orientation.][1] [1]: http://stackoverflow.com/questions/4917664/detect-viewport-orientation-if-orientation-is-portrait-display-alert-message-ad – Akshaya Raghuvanshi Apr 06 '13 at 19:12

1 Answers1

0

First create even handler

$(window).on("mousewheel", function() {
    alert($(document).scrollTop());
}

Then just call

$(window).mousewheel();

Hope it will help.

Sergey
  • 7,933
  • 16
  • 49
  • 77