Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

ScrollTop not working in Firefox

more options

I'm trying to simulate smooth scrolling between panels and add an active state to links when the top of the panel reaches the top of the viewport. Everything was going great until I tested in Firefox. Scrolling between panels is jagged, and the active state is added to the wrong link at times. Here's my code:

$(document).ready(function () {
  $(window).scroll(function () {
    var y = $(this).scrollTop();
    $('.link').each(function (event) {
      if (y >= $($(this).attr('href')).offset().top - 0) {
        $('.link').not(this).removeClass('active');
        $(this).addClass('active');
      }
    });
  });
});

// SMOOTH SCROLLING

$(function () {
  $('a[href*=#]:not([href=#])').click(function () {
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: (target.offset().top - 0)
        }, 850);
        return false;
      }
    }
  });
});

Also you can see the page I'm working on here: http://zebron.github.io/

I'm trying to simulate smooth scrolling between panels and add an active state to links when the top of the panel reaches the top of the viewport. Everything was going great until I tested in Firefox. Scrolling between panels is jagged, and the active state is added to the wrong link at times. Here's my code: <pre><nowiki>$(document).ready(function () { $(window).scroll(function () { var y = $(this).scrollTop(); $('.link').each(function (event) { if (y >= $($(this).attr('href')).offset().top - 0) { $('.link').not(this).removeClass('active'); $(this).addClass('active'); } }); }); }); // SMOOTH SCROLLING $(function () { $('a[href*=#]:not([href=#])').click(function () { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html,body').animate({ scrollTop: (target.offset().top - 0) }, 850); return false; } } }); });</nowiki></pre> Also you can see the page I'm working on here: http://zebron.github.io/

Được chỉnh sửa bởi cor-el vào

Tất cả các câu trả lời (6)

more options

This forum focuses more on end-user support, so might not be the best place to get an answer on this. You can find more web development help on the unofficial mozillaZine Web Development board. It's a separate site with separate registration. For best results, please note the tips in the Sticky Post at the top of the forum before posting.

more options

By the way, I'm getting lots of scrolling as I click the years, but at some point, there is an issue with accuracy: I get scrolled to one year earlier than I chose. Not sure if you are seeing that.

Oh, that was your second point. I just didn't understand the reference.

Được chỉnh sửa bởi jscher2000 - Support Volunteer vào

more options

Thanks jscher. I've posted to Stack Overflow and did see plenty of technical questions answered here previously so I assumed that was one of the purposes of this forum.

more options

Well, we often comment on website issues, I'm just saying don't hold your breath. ;-)

By the way, does your Firefox have hardware acceleration active? You can confirm by checking the "GPU Accelerated Windows" count on the support information page (either):

  • "3-bar" menu button > "?" button > Troubleshooting Information
  • (menu bar) Help > Troubleshooting Information
  • type or paste about:support in the address bar and press Enter
more options

This is what that interface says: 1/1 OpenGL (OMTC)

more options

Yes, hardware acceleration is active. Thanks.