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

@ophiuchus/sticky

v1.0.1

Published

### 介绍

Downloads

2

Readme

Sticky 粘性布局

介绍

Sticky 组件与 CSS 中position: sticky属性实现的效果一致,当组件在屏幕范围内时,会按照正常的布局排列,当组件滚出屏幕范围时,始终会固定在屏幕顶部。

引入

import Vue from 'vue';
import Sticky from '@ophiuchus/sticky';

Vue.use(Sticky);

代码演示

基础用法

将内容包裹在 Sticky 组件内即可。

<sf-sticky>
  <sf-button type="primary">基础用法</sf-button>
</sf-sticky>

吸顶距离

通过 offset-top 属性可以设置组件在吸顶时与顶部的距离。

<sf-sticky :offset-top="50">
  <sf-button type="info">吸顶距离</sf-button>
</sf-sticky>

指定容器

通过 container 属性可以指定组件的容器,页面滚动时,组件会始终保持在容器范围内,当组件即将超出容器底部时,会固定在容器的底部。

<div ref="container" style="height: 150px;">
  <sf-sticky :container="container">
    <sf-button type="warning">指定容器</sf-button>
  </sf-sticky>
</div>
export default {
  data() {
    return {
      container: null,
    };
  },
  mounted() {
    this.container = this.$refs.container;
  },
};

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | offset-top | 吸顶时与顶部的距离,支持 px vw vh rem 单位,默认 px | number | string | 0 | | z-index | 吸顶时的 z-index | number | string | 99 | | container | 容器对应的 HTML 节点 | Element | - |

Events

| 事件名 | 说明 | 回调参数 | | --- | --- | --- | | change | 当吸顶状态改变时触发 | isFixed: boolean | | scroll | 滚动时触发 | { scrollTop: number, isFixed: boolean } |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | --------------- | ------ | ---- | | @sticky-z-index | 99 | - |