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

@rax-ui/filter-helper

v1.0.0-beta.15

Published

--- display: __ComponentName__ family: other ---

Downloads

1

Readme


display: ComponentName family: other

@rax-ui/filter-helper

@rax-ui/filter 组件的帮助工具,提供滚动吸附功能滚动到具体位置功能

API

  • withSticky:高阶组件,可提供在 RecycleView 组件中滚动吸附,兼容 weex/web 环境,【只支持RecycleView组件中使用】
    • 函数签名`:Function(Wrapped: JSX.Element) => Wrapped
      • Wrapped: JSX.Element:被包裹的组件,目前仅支持 RecycleView.Header
  • scrollIntoView:在滚动容器中,滚动到特定节点,滚动容器支持RecycleViewScrollView
    • 函数签名`:Function(node: any, container: any, animated = true, offset = 0) => void
      • node: 要滚动到的 dom 节点
      • container: 当前滚动容器 dom 节点
    • animated:是否动画
    • offset:滚动到node节点的 offset 距离

Demo

import { createElement, render, Component } from 'rax';
import DriverUniversal from 'driver-universal';
import View from 'rax-view';
import Text from 'rax-text';
import RecycleView from 'rax-recyclerview';
import findDOMNode from 'rax-find-dom-node';
import { withSticky, scrollIntoView } from '@rax-ui/filter-helper';

const StickyHeader = withSticky(RecycleView.Header);

class Demo extends Component {
  handleClick = () => {
    scrollIntoView(findDOMNode(this.refSticky), findDOMNode(this.refRecycleView), false);
  };
  render() {
    return (
      <View style={styles.page}>
        <RecycleView
          style={styles.recycle}
          ref={r => {
            this.refRecycleView = r;
          }}
        >
          {buildData(3).map((val, index) => {
            return (
              <RecycleView.Cell>
                <View key={'1' + index} style={styles.item}>
                  <Text>Top UI</Text>
                </View>
              </RecycleView.Cell>
            );
          })}
          <StickyHeader
            ref={r => {
              this.refSticky = r;
            }}
          >
            <View onClick={this.handleClick} style={styles.stickyItem}>
              <Text>Sticky Item, Click Me</Text>
            </View>
          </StickyHeader>

          {buildData(50).map((val, index) => {
            return (
              <RecycleView.Cell>
                <View key={'2' + index} style={styles.item}>
                  <Text>List Item {index}</Text>
                </View>
              </RecycleView.Cell>
            );
          })}
        </RecycleView>
      </View>
    );
  }
}
function buildData(length, text = '') {
  return new Array(length)
    .join(0)
    .split('')
    .map((item, index) => {
      return {
        text: text + index,
        value: String(index)
      };
    });
}

const styles = {
  page: {
    width: 750,
    height: 1334
  },
  recycle: {
    width: 750,
    height: 1246
  },
  stickyItem: {
    width: 750,
    height: 100,
    backgroundColor: 'green',
    justifyContent: 'center',
    alignItems: 'center'
  },
  item: {
    width: 750,
    height: 300,
    backgroundColor: '#eaeaea',
    justifyContent: 'center',
    alignItems: 'center'
  }
};

render(<Demo />, null, { driver: DriverUniversal });