1.0.0 • Published 4 years ago

@eyeear/fixed v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

Fixed

元素吸顶固定。

安装

npm install @eyeear/fixed --save

使用

import Fixed from '@eyeear/fixed'

OR

<script src="lib/fixed.js"></script>
  <div class="box">我会固定</div>
  <div class="wrapper" style="height:2000px;">我很高</div>
  // 固定到顶部
  new Fixed('.box')

 // 固定到离顶部100px的位置 层级200
 new Fixed('.box', {
   top: 100,
   zIndex: 200
 })

  // 固定到顶部 当(wrapper)元素不可见时取消固定
  new Fixed('.box', {
    range: '.wrapper'
  })

选项

  new Fixed(el, options)

  el 
    - 必须设置 吸顶的元素 一个css选择器或者元素对象
  
  options
    - top 固定位置(相对顶部)  默认 0 
    - zIndex z-index层级 默认 1
    - range 范围容器 其可见影响元素吸顶 默认未指定
    - fixedClass 为实际固定元素加的类名 复杂情形下可手动设置样式 默认'fixed___wrapper'