Fakescroll
vanilla-js lightweight custom HTML scrollbar
Install / Use
/learn @yairEO/FakescrollREADME
- 1.4KB gzipped (js)
- 4.0KB minified (js)
- 7.7KB unminified (js)
- ~20+ KB avarage similar scripts (unminified)
Currently only supports vertical scroll due to cultural norms
While there is somewhat of a support for scrollbar customization through CSS, it is not fully supported in all browsers / older versions and the level of customization isn't flexible enough to allow creativity or certain special product needs.
👉 Make sure to import fakescroll.css
Install (CDN):
npm i @yaireo/fakescroll
React port
import FakeScroll from '@yaireo/fakescroll/react.fakescroll.js'
import '@yaireo/fakescroll/fakescroll.css'
const onFakeScrollChange = ({ scrollRatio }) => console.log(scrollRatio)
<FakeScroll className='foo' track='smooth' onChange={onFakeScrollChange}>
...
</FakeScroll>
Example markup:
<div class="foo">
...
...
...
</div>
Initialize custom scrollbar with callback:
var myScrollbar = document.querySelector('.foo').fakeScroll({
onChange: () => console.log( myScrollbar.scrollRatio )
})
The onChange also has a scrollRatio propery in its argument:
document.querySelector('.foo--outside').fakeScroll({
onChange: ({ scrollRatio }) => console.log( scrollRatio )
});
The above markup will now become:
<div class="foo fakeScroll fakeScroll--hasBar">
<div class="fakeScroll__wrap">
<div class="fakeScroll__content">
...
...
...
</div>
</div>
<div class="fakeScroll__bar"></div>
</div>
Browser support
The script probably won't work on IE without Babel & ES2015 polyfills.
DEMO PAGE
Settings
Name | Type | Default | Info ------------------- | ---------- | ----------- | -------------------------------------------------------------------------- classname | String | "" | Class name which is added to the scrollbar Track element track | Boolean/String | false | enable track events. use "smooth" for smooth "jumping" onChange | Function | | Callback function whenever the scroll updates
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
