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

react-native-yet-another-sortable

v1.0.0

Published

Drag-and-drop sortable scrollable grid view for React Native.

Downloads

460

Readme

react-native-yet-another-sortable

Build Status

A sortable scrollable grid / list component for React Native.

  • Change number of columns and row height on the fly
  • Much better performance (especially in debug, compared to alternatives)
  • Fast updates
  • Controllable order
  • Auto-scroll when dragged item is close to the container's border Essentially based on react-native-sortable-grid, it has some improvements and changes, that made me publish it as a separate package instead of making a PR.

Getting Started

Installation

npm install react-native-yet-another-sortable --save

Usage

Check out example project.

import React, { useState, useCallback } from 'react';
import SortableGrid from 'react-native-yet-another-sortable';

const Example = () => {
  const [data] = useState([
    { value: 0, key: 'key0' },
    { value: 1, key: 'key1' },
    { value: 2, key: 'key2' },
  ]);

  const [order, setOrder] = useState(['key2', 'key1', 'key0']);

  const renderItem = useCallback(({ value, color }) => (
    <View style={{ flex: 1 }}>
      <Text>{value}</Text>
    </View>
  ), []);

  return (
    <View style={{ flex: 1 }}>
      <SortableGrid
        order={order}
        data={data}
        renderItem={renderItem}
        onDeactivateDrag={setOrder}
      />
    </View>
  );
};

Props

| parameter | type | required | description | | :-------- | :---- | :------- | :---------- | | order | array of string keys | yes | array of data key properties used to determine entry order | | data | array of objects with key property | yes | array of items to be passed to renderItem | | rowHeight | number | no | row height | | columns | number | no | number of columns per row | | activationTreshold | number | no | time in ms required to activate drag on hold | | transitionDuration | number | no | time in ms required to move cell to its position on release | | renderItem | function | yes | render function for each entry, is passed a data item |

Event props

| parameter | type | required | description | | :-------- | :---- | :------- | :---------- | | onActivateDrag | (key, grid) => void | no | Will execute after one holds the item for activateTreshold, before onGrantBlock | | onGrantBlock | (event, gestureState, grid) => void | no | Will execute on drag start | | onMoveBlock | (event, gestureState, grid) => void | no | Will execute on each move | | onReleaseBlock | (event, gestureState, grid) => void | no | Will execute on drag release | | onDeactivateDrag | (order, grid) => void | no | Will execute on active item drop, after onReleaseBlock, with new order as an argument |

Data item props

| parameter | type | required | description | | :-------- | :---- | :------- | :---------- | | inactive | boolean | no | Makes block not draggable | | key | string | yes | key used to order items

Development

In order to develop the application or build android .apk from the sources one should:

  1. Clone this repository
  2. Install package dependencies with npm install
  3. Navigate to example folder: cd example
  4. Install example project dependencies npm install
  5. Run Metro bundler with react-native start
  6. Connect an emulator or physical device via adb, like this (tested with mEMU):
    • adb connect 127.0.0.1:21503
    • adb reverse tcp:8081 tcp:8081
  7. Build and watch with react-native run-android, changes from src directory are picked automatically because of example's metro and babel configurations.

Contributions

PR are always welcome!

Todos

  • Better scroll-on-drag behaviour (smooth scroll without ugly timeouts and large scroll results in the dragged block trembling)
  • Refactoring while perserving the performance
  • Actual tests