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/pull-refresh

v1.0.2

Published

### 介绍

Downloads

8

Readme

PullRefresh 下拉刷新

介绍

用于提供下拉刷新的交互操作。

引入

import Vue from 'vue';
import PullRefresh from '@ophiuchus/pull-refresh';

Vue.use(PullRefresh);

代码演示

基础用法

下拉刷新时会触发 refresh 事件,在事件的回调函数中可以进行同步或异步操作,操作完成后将 v-model 设置为 false,表示加载完成。

<sf-pull-refresh v-model="isLoading" @refresh="onRefresh">
  <p>刷新次数: { { count } }</p>
</sf-pull-refresh>
import Toast  from '@ophiuchus/toast';

export default {
  data() {
    return {
      count: 0,
      isLoading: false,
    };
  },
  methods: {
    onRefresh() {
      setTimeout(() => {
        Toast('刷新成功');
        this.isLoading = false;
        this.count++;
      }, 1000);
    },
  },
};

成功提示

通过 success-text 可以设置刷新成功后的顶部提示文案。

<sf-pull-refresh
  v-model="isLoading"
  success-text="刷新成功"
  @refresh="onRefresh"
>
  <p>刷新次数: { { count } }</p>
</sf-pull-refresh>

自定义提示

通过插槽可以自定义下拉刷新过程中的提示内容。

<sf-pull-refresh v-model="isLoading" :head-height="80" @refresh="onRefresh">
  <!-- 下拉提示,通过 scale 实现一个缩放效果 -->
  <template #pulling="props">
    <img
      class="doge"
      src="https://img01.yzcdn.cn/vant/doge.png"
      :style="{ transform: `scale(${props.distance / 80})` }"
    />
  </template>

  <!-- 释放提示 -->
  <template #loosing>
    <img class="doge" src="https://img01.yzcdn.cn/vant/doge.png" />
  </template>

  <!-- 加载提示 -->
  <template #loading>
    <img class="doge" src="https://img01.yzcdn.cn/vant/doge-fire.jpg" />
  </template>
  <p>刷新次数: { { count } }</p>
</sf-pull-refresh>

<style>
  .doge {
    width: 140px;
    height: 72px;
    margin-top: 8px;
    border-radius: 4px;
  }
</style>

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | v-model | 是否处于加载中状态 | boolean | - | | pulling-text | 下拉过程提示文案 | string | 下拉即可刷新... | | loosing-text | 释放过程提示文案 | string | 释放即可刷新... | | loading-text | 加载过程提示文案 | string | 加载中... | | success-text | 刷新成功提示文案 | string | - | | success-duration | 刷新成功提示展示时长(ms) | number | string | 500 | | animation-duration | 动画时长 | number | string | 300 | | head-height | 顶部内容高度 | number | string | 50 | | pull-distance | 触发下拉刷新的距离 | number | string | 与 head-height 一致 | | disabled | 是否禁用下拉刷新 | boolean | false |

Events

| 事件名 | 说明 | 回调参数 | | ------- | -------------- | -------- | | refresh | 下拉刷新时触发 | - |

Slots

| 名称 | 说明 | 参数 | | ------- | -------------------- | -------------------------- | | default | 自定义内容 | - | | normal | 非下拉状态时顶部内容 | - | | pulling | 下拉过程中顶部内容 | { distance: 当前下拉距离 } | | loosing | 释放过程中顶部内容 | { distance: 当前下拉距离 } | | loading | 加载过程中顶部内容 | { distance: 当前下拉距离 } | | success | 刷新成功提示内容 | - |

样式变量

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

| 名称 | 默认值 | 描述 | | ----------------------------- | --------------- | ---- | | @pull-refresh-head-height | 50px | - | | @pull-refresh-head-font-size | @font-size-md | - | | @pull-refresh-head-text-color | @gray-6 | - |

常见问题

PullRefresh 的内容未填满屏幕时,只有一部分区域可以下拉?

默认情况下,下拉区域的高度是和内容高度保持一致的,如果需要让下拉区域始终为全屏,可以给 PullRefresh 设置一个与屏幕大小相等的最小高度:

<sf-pull-refresh style="min-height: 100vh;" />

在桌面端无法操作组件?

参见桌面端适配