npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fekit/fixed

v2.0.0

Published

指定元素滚动到窗口指定位置时固定在指定位置。

Downloads

3

Readme

@fekit/fixed

指定元素滚动到窗口指定位置时固定在指定位置。

索引

演示

https://plugins.fekit.cn/@fekit/fixed/

开始

下载项目:

npm i @fekit/fixed

参数

  @param  param              {Object}    * 入参
  @param  param.el           {Element}   * 需要监听的DOM节点
  @param  param.area         {Element}     作用范围区域 (选填,默认为body)
  @param  param.wrap         {Element}     动态参考元素 (选填,如不填写则为其父元素)
  @param  param.top          {String}      偏移量值 (选填,默认为0)
  @param  param.fixedStyle   {String}      固定时的样式
  @param  param.fixedClass   {String}      固定时的CLASS
  @param  param.autoStyle    {Boolean}     自是开启动动样式
  @param  param.on           {Object}      回调集
  @param  param.fixed        {Function}    固定时
  @param  param.reduced      {Function}    还原时

示例

前置条件

// 使用此插件,必须在需要固定的元素外面包一层容器,且此容器尺寸与位置必须和固定元素一样大小或不设置任何尺寸与位置属性。
<div>
  <div id="el"></div>
</div>
// 楼层埋点插件
import McFixed from '@fekit/fixed';

// 新建一个在ID为f3的区域范围内滚动到顶部60px时固定的实例。
new McFixed({
  el: document.getElementById('f3_tab'),
  area: document.getElementById('f3'),
  zIndex: 999,
  top: 60,
});

// 设置一个不设定作用范围的实例,默认为整个body区域,顶部为0时固定的实例,并且设置层级为1001,固定时触发一个回调。
new McFixed({
  el: document.getElementById('f1_tab'),
  fixedClass: 'f1_fixed', // 在这个设置的class下写固定后的样式
  on: {
    fixed() {
      console.log(_this);
    },
  },
});

版本

v2.0.0 [Latest version]
1. TS重构
v1.1.2
1. 优化插件对外部使用环境的容错能力
v1.1.0
1. 优化当导航尺寸发生变化时的自适应功能
v1.0.8
1. 优化当窗口发生变化时的自适应功能
v1.0.7
1. 优化当窗口发生变化时的自适应功能
v1.0.6
1. 还是那个className的bug
v1.0.5
1. 修复一个处理className的bug
v1.0.4
1. 原fixedCss入参属性名改为fixedStyle。用法未变。
2. 新增一个fixedClass入参,当固定时设置一个class,这个class可以预先写好固定时的样式。当设有fixedClass时fixedStyle仅设置top,其它样式需要在class中写样式。
3. 固定或还原状态切换时仅触发一次事件。原来是只要滚动就不停的触发固定或还原事件。
v1.0.3
1. 非核心优化
v1.0.2
1. 非核心优化
v1.0.1
1. 修复安卓兼容性问题
2. 优化指定区域内显示的元素在区域滚动到底部时元素跟随区域底部渐渐滚出可视区外。
v1.0.0
1. 此版本完成了核心功能。

反馈

如果您在使用中遇到问题,请通过以下方式联系我。
QQ: 860065202
EMAIL: [email protected]