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

remax-virtual-list-zhou

v1.0.5

Published

remax virtual list

Downloads

9

Readme

remax 虚拟滚动列表组件(暂时只支持微信,支付宝没测试)

只支持等高项的列表

Install

npm install remax-virtual-list-zhou --save-dev
# or 
yarn add -D remax-virtual-list-zhou

Usage

import React, { useEffect, useMemo, useRef, useState } from "react";
import { View, Text, Image } from "remax/one";
import { ScrollView } from "remax/wechat";
import { useNativeEffect } from "remax";
import styles from "./index.css";
import VirtualList from "@/components/VirtualList";

const mockData: any[] = [];
for (let i = 0; i < 1000; i++) {
  mockData.push({
    text: `第${i}项`,
  });
}

export default () => {
  const [data, setData] = useState(mockData.slice(0, 10));
  const ref = useRef<any>();
  const handleScroll = (e: any) => {
    ref.current?.onScroll(e);
  };

  const systemInfo = useMemo(() => {
    return wx.getSystemInfoSync();
  }, []);

  const [scrollViewHeightPx, setScrollViewHeightPx] = useState(0);
  useNativeEffect(() => {
    wx.createSelectorQuery()
      .select("#scroll-view")
      .boundingClientRect(function (rect) {
        setScrollViewHeightPx(rect.height);
      })
      .exec();
  }, [data]);
  return (
    <View className={styles.app}>
      <ScrollView
        onScrollToLower={() => {
          setTimeout(() => {
            setData(data.concat(mockData.slice(data.length, data.length + 10)));
          }, 100);
        }}
        style={{ height: "100vh" }}
        scrollY
        onScroll={handleScroll}
        lowerThreshold={350}
        id="scroll-view"
      >
        <VirtualList
          scrollViewHeightPx={scrollViewHeightPx}
          windowWidth={systemInfo.windowWidth}
          placeholderImage="https://sl-online-oss.shulidata.com/jiyang/wechat/placeImage.png"
          ref={ref}
          data={data}
          itemHeight={300}
          renderItem={(item, index) => (
            <View key={item.text} style={{ height: 300 }}>
              {item.text}
            </View>
          )}
          onExposure={(index) => {
            console.log("Exposure", index);
          }}
          renderBottom={() => (
            <View className={styles.loading}>加载中。。</View>
          )}
        />
      </ScrollView>
    </View>
  );
};

Options

| Option | type | default | desc | | ------------------ | -------- | ------- | ------------------------------------------------------------------------- | | windowWidth | number | 无 | 必填,可使用窗口宽度,单位px ,通过wx.getSystemInfoSync()获取,用于单位转换 | | data | array | [] | 必填,列表数据 | | renderItem | function | 无 | 必填,每一项的渲染方法 | | placeholderImage | string | 无 | 建议填,占位图片 | | overscanCount | number | 12 | 一屏数量,默认共显示3*12项 | | headerHeight | number | 无 | 渲染列表头部时必填 | | renderHeader | function | 无 | 渲染列表头部 | | renderBottom | function | 无 | 渲染列表底部 | | onExposure | function | 无 | 曝光方法,(index)=>{} ,index从0开始,数组下标 | | scrollViewHeightPx | function | 无 | 单位px,曝光方法必要参数 |