v-scroll-affix
v0.0.4
Published
A lightweight vue component for affixing an element as you scroll. 轻量级 vue 固钉组件。
Downloads
8
Readme
v-scroll-affix
A lightweight lib for making navigation elements affix as you scroll, a wrapper of scroll-affix .
在滚动时激活固钉的轻量级 vue 组件,封装自 scroll-affix 。
Live Demo
Installation
npm install v-scroll-affix --save
Usage
<div id="app" class="container">
<div class="main">this is main content.</div>
<div class="right-menu">
<VScrollAffix :offsetTop="20" sectionSelector="#app .main">
<ul>
<li>this is a list</li>
<li>this is a list</li>
<li>this is a list</li>
<li>this is a list</li>
<li>this is a list</li>
<li>this is a list</li>
</ul>
</VScrollAffix>
</div>
</div>
// window
// const VScrollAffix = window['VScrollAffix'];
// commonjs like
// const VScrollAffix = require('v-scroll-affix');
// es module, typescript
import VScrollAffix from './VScrollAffix.vue';
// Vue.use(VScrollAffix); // global
export default {
components: {
VScrollAffix // local
}
};
Props
| name | type | default | description |
| :-------------- | :--------------------: | :-----: | :--------------------------------------------------------------------------------------------- |
| offsetTop | number
| 0
| offsetTop to affix element 浮动的 y 轴偏移量 |
| maxScrollHeight | number
、()=>number
| | max height to affix element 自定义可浮动区域的最大高度 |
| sectionSelector | string
| | get max height to affix element by section element 根据关联区域动态获取可浮动区域最大高度 |