jquery-scrollstop

A jQuery plugin that fires events when scrolling stops and starts.

Github星跟蹤圖

jquery-scrollstop

This plugin fires two events on window when scrolling starts and stops:
scrollstart and scrollstop.

Example

The example shows a small box in the upper left that says "SCROLLING" and
colors the body different colors when scrolling:
https://ssorallen.github.io/jquery-scrollstop/

Usage

scrollstart fires after the first scroll event and won't fire again until
after a scrollstop event is fired.

scrollstop fires after no scroll events have fired for 250 milliseconds.

$(window)
  .on("scrollstart", function() {
    // Paint the world yellow when scrolling starts.
    $(document.body).css({background: "yellow"});
  })
  .on("scrollstop", function() {
    // Paint it all green when scrolling stops.
    $(document.body).css({background: "green"});
  })

Configuration

latency

latency is the minimum time between the last scroll event and when the
scrollstop event fires. Set $.event.special.scrollstop.latency to the
desired number of milliseconds (default: 250).

// Configure time between final scroll event and
// `scrollstop` event to 650ms (default is 250ms).
$.event.special.scrollstop.latency = 650;
latency per element

Latency can be configured per-element by passing options when the event listener
is bound. If multiple event listeners are bound to the same element, only the
data from the first event listener will set the configuration.

// Configure latency to 650ms for #scrolling-div
$("#scrolling-div").on("scrollstop", {latency: 650}, function() { ... });

jQuery Version Support

The plugin is tested in jQuery 1.2.3+ and jQuery 2.0.3+.

Attribution

Originally code taken from James Padolsey's blog:
http://james.padolsey.com/javascript/special-scroll-events-for-jquery/

主要指標

概覽
名稱與所有者ssorallen/jquery-scrollstop
主編程語言HTML
編程語言JavaScript (語言數: 2)
平台
許可證The Unlicense
所有者活动
創建於2012-06-26 18:50:54
推送於2020-06-09 16:08:52
最后一次提交2020-06-09 11:08:51
發布數4
最新版本名稱v1.2.0 (發布於 )
第一版名稱v1.0.0 (發布於 )
用户参与
星數157
關注者數15
派生數60
提交數36
已啟用問題?
問題數3
打開的問題數0
拉請求數1
打開的拉請求數0
關閉的拉請求數2
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?