Localscroll / ScrollTo не работи на iPad

Имам проблеми с localscroll - имам фиксиран заглавен елемент, който се появява след около 100 пиксела от върха. Когато потребителят щракне върху елемента за навигация, той се превърта до правилната позиция, но след това, когато се опитам да щракна върху друг елемент от менюто, той няма да се премести, освен ако не преместя страницата много леко.

Това се случва само на iPad - работи добре в настолни браузъри.

Някой има ли идеи?

var sections = $('section,footer'),
links = $('nav a');
$(window).scroll(function() {
    var currentPosition = $(this).scrollTop();
    links.removeClass('selected');

    sections.each(function() {
        var top = $(this).offset().top - 100,
            bottom = top + $(this).height();

        if (currentPosition >= top && currentPosition <= bottom) {
            $('a[href="/bg#' + this.id + '"]').addClass('selected');
        }
        if ($(window).scrollTop() + $(window).height() == $(document).height()) {
            links.removeClass('selected');
            $('.last a').addClass('selected');
        }
    });
});
$.localScroll();

person user1788364    schedule 06.12.2013    source източник


Отговори (1)


Успях да намеря корекцията чрез тук: https://gist.github.com/mckamey/1e661854044177a95064

(function(){
var THROTTLE = 100,//ms
    _timer = 0,
    _dom = document.documentElement,
    _width = _dom.style.width,
    reset = function(){
        // reset size, unfortunately forces another reflow
        _dom.style.width = _width;
    },
    forceReflow = function(){
        if (_timer) {
            clearTimeout(_timer);
            _timer = 0;
        }

        _width = _dom.style.width;

        // force a reflow by increasing size 1px
        _dom.style.width = (_dom.offsetWidth+1)+'px';

        setTimeout(reset, 0);
    },
    onscroll = function() {
        if (_timer) {
            clearTimeout(_timer);
        }
        _timer = setTimeout(forceReflow, THROTTLE);
    };

window.addEventListener('scroll', onscroll, false);
})();
person user1788364    schedule 06.12.2013