jQuery 航點在 Safari 中不起作用 (jQuery waypoints not working in Safari)


問題描述

jQuery 航點在 Safari 中不起作用 (jQuery waypoints not working in Safari)

Example Page works pretty much as desired in FF & Chrome but not in Safari. There are some position changes (from fixed to static back to fixed) but I'm not aware of any issues Safari has w/positioning (non mobile safari). Below is my code:

$(function(){
    var footerPos = function () {
        var w = $(window).height();
        var top = (w‑110);
        $('footer').css('top', top);
    };
    $(document).ready(footerPos);
    $(window).resize(footerPos);
    $('footer').waypoint(function(direction) {
        if (direction === 'down') {
            $('footer').css({'position':'static'}).animate({'height':'600px', 'top':'auto'}, 400, footerPos) ;
            $('.tfContent').css({'height':'200px'});
            $('p.extra').fadeIn('fast');
            $('#arrow').addClass('arrowDown');
            console.log('down');
        } else if (direction === 'up') {
            $('.tfContent').css({'background':'white'});
            $('footer').css({'position':'fixed','top':footerPos});
            $('.tfContent').css({'height':'60px'});
            $('p.extra').slideUp('fast');
            $('#arrow').removeClass('arrowDown');
                console.log('up');
        }
        }, { offset: 'bottom‑in‑view' });

If you look in Chrome first, you will see when you scroll to the bottom of the page the white content ('.tfContent') expands down, the 'footer' changes from fixed to static position and increases it's height. But not in Safari. Any ideas? ALSO: is there any way to make the page scroll to the bottom in the waypoints function? This, for some reason doesn't work

$('html, body').animate({scrollTop: $(document).height()‑$(window).height()}, 1400, "easeOutQuint");

參考解法

方法 1:

I don't have an answer to your specific code, but in general using a fixed position element as the waypoint (footer here) is not going to work the way you expect. Waypoints works by looking at an element's scroll position in relation to the document, and fixed position elements are always changing in that regard.

(by Dirty Bird Designimakewebthings)

參考文件

  1. jQuery waypoints not working in Safari (CC BY‑SA 3.0/4.0)

#safari #jquery #jquery-waypoints






相關問題

如何讓 <asp:menu> 在 Safari 中工作? (How can I get <asp:menu> working in Safari?)

jQuery 航點在 Safari 中不起作用 (jQuery waypoints not working in Safari)

iOS WebApp 不顯示啟動圖像 (iOS WebApp not showing startup image)

Jquery、Javascript 點擊菜單在 IE 和 Safari 上不起作用 (Jquery, Javascript click menu doesnt work on IE and Safari)

如果我沒有 Mac 和 Safari,我將如何重現 Javascript 錯誤? (How am I going to reproduce Javascript bugs if I don't have a Mac & Safari?)

Webkit 中的全局 Javascript 變量 (Global Javascript variables in Webkit)

Safari IndexOutOfRangeException (safari IndexOutOfRangeException)

Safari 2.0 中修改鍵的鍵盤事件 (Keyboard Events for Modifier Keys in Safari 2.0)

通過 HTML 在 Mobile Safari 上實現 UIPickerview (Implement UIPickerview on Mobile Safari via HTML)

Safari 的 jQuery 問題 (jQuery problem with Safari)

網頁上的音頻被截斷 (Audio cuts out on webpages)

當選項卡不活動時,保持 JS/jQuery 代碼在 Safari 中工作 (Keep the JS/jQuery code working in Safari when the tab is not active)







留言討論