vue-affix-box

A vue plugin to fix the element on your applications
924
Install
npm install vue-affix-box
Latest Version:1.0.1
Vue:2
License:ISC
Last Updated:Jan 26, 2021
Links: npm
Maintainer: xiaocheng555

vue-affix-box

一个Vue插件,能将页面元素钉在可视范围。

Demo

Demo

快速使用

安装

$ npm i vue-affix-box -S

or

$ yarn add vue-affix-box

引入

全局引入:

import Vue from 'vue'
import VueAffixBox from 'vue-affix-box'

Vue.component('vue-affix-box', VueAffixBox)

局部引入:

import VueAffixBox from 'vue-affix-box'

export default {
  components: {
    VueAffixBox
  },
  ...
}

使用

<vue-affix-box :offset-top="100">
  <div>固定顶部</div>
</vue-affix-box>

<vue-affix-box :offset-bottom="100">
  <div>固定底部</div>
</vue-affix-box>

API

vue-affix-box组件与ant-design的affix组件的API保持一致,并在此基础上进行了扩展。

Props

参数 说明 类型 可选值 默认值
offsetTop 距离窗口顶部达到指定偏移量后触发 number — 0
offsetBottom 距离窗口底部达到指定偏移量后触发 number — —
target 设置 Affix 需要监听其滚动事件的元素 string/object — window
reference 设置 Affix 相对固定的元素 string/object — —
zIndex z-index 堆叠顺序 number — 10
throttleLimit 滚动事件的节流时间 number — 50
disabled 是否禁用 boolean — false

Methods

方法名 说明 参数
updatePosition 更新 Affix 位置 —

Events

事件名称 说明 回调参数
change 固定状态改变时触发的事件 当前固定状态

Related Packages

vue-affix

A Vue.js plugin that affixes an element in the window while you scroll, similar...

153,389 405
vue-sticky

A directive to sticky element for vue.js.

115,846 161
vue-position-sticky

A Vue.js components to sticky to the page

5,657 11
vue-sticky-position

A Vue.js sticky position component

2,232 30

Version History

Version Released Vue License
1.0.1 ^2.6.10 ISC
1.0.0 ^2.6.10 ISC