jQuery

【jQuery】軽量のスティッキーStickybits

May 12, 2017
stickybits

Stickybitsは、軽量(<2KB)のスティッキー。

Setup

stickybits.min.jsを追加

Basic Usage

stickybits('selector');

useStickyClassesを使用。

stickybits('selector', {useStickyClasses: true});

CSS

.some-sticky-element .js-is-sticky {
  background-color: red;
}
.some-sticky-element .js-is-stuck {
  background-color: green;
}

Options

Vertical Layout Position

stickybits('selector', {verticalPosition: 'bottom'});

StickyBit Sticky Offset

stickybits('selector', {stickyBitStickyOffset: 20});

MIT