How to use the array-move function in array-move

To help you get started, we’ve selected a few array-move examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clauderic / react-sortable-hoc / examples / react-virtualized.js View on Github external
onSortEnd = ({oldIndex, newIndex}) => {
    if (oldIndex === newIndex) {
      return;
    }

    const {items} = this.state;

    this.setState({
      items: arrayMove(items, oldIndex, newIndex),
    });

    // We need to inform React Virtualized that the items have changed heights
    // This can either be done by imperatively calling the recomputeRowHeights and
    // forceUpdate instance methods on the `List` ref, or by passing an additional prop
    // to List that changes whenever the order changes to force it to re-render
    this.List.recomputeRowHeights();
    this.List.forceUpdate();
  };
github fanfoujs / space-fanfou / src / features / favorite-fanfouers / home@page.js View on Github external
onSortEnd = ({ oldIndex, newIndex }) => {
      const newValue = arrayMove(this.state.friendsData, oldIndex, newIndex)

      this.setFriendsList(newValue)
    }
github contentful / extensions / lib / shared-sku-app / src / Editor / SortableComponent.tsx View on Github external
onSortEnd = ({ oldIndex, newIndex }: { oldIndex: number; newIndex: number }) => {
    const skus = arrayMove(this.props.skus, oldIndex, newIndex);
    this.props.onChange(skus);
  };
github clauderic / react-sortable-hoc / examples / react-virtualized-table-columns.js View on Github external
this.setState(({cols}) => ({
      cols: arrayMove(cols, oldIndex, newIndex),
    }));
  };
github helpscout / hsds-react / stories / MessageList.stories.js View on Github external
onSortEnd = ({ oldIndex, newIndex }) => {
      const { items } = this.state
      this.setState({
        items: arrayMove(items, oldIndex, newIndex),
      })
    }
github heartexlabs / label-studio / src / interfaces / control / List.js View on Github external
moveItems({ oldIndex, newIndex }) {
      if (oldIndex === newIndex) return;

      if (self.sortedhighlightcolor) {
        self.regions[oldIndex].setBG(self.sortedhighlightcolor);
      }

      self.regions[oldIndex].setSelected(true);

      if (self._value) self._value = arrayMove(self._value, oldIndex, newIndex);

      self.regions = arrayMove(self.regions, oldIndex, newIndex);
      self.setUpdate();
    },
github clauderic / react-sortable-hoc / examples / basic.js View on Github external
this.setState(({items}) => ({
      items: arrayMove(items, oldIndex, newIndex),
    }));
  };
github maximakymenko / react-sortable-hoc-article-app / src / App.js View on Github external
const onSortEnd = ({ oldIndex, newIndex, collection }) => {
    switch (collection) {
      case 'gifs':
        setGifs(arrayMove(gifs, oldIndex, newIndex))
        break;
      case 'newGifs':
        setNewGifs(arrayMove(newGifs, oldIndex, newIndex))
        break;
      default:
        break;
    }
  }

array-move

Move an array item to a different position

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular array-move functions