Giter VIP home page Giter VIP logo

react-sortable-pane's Introduction

Sortable and resizable pane component for react.

CircleCI Build Status

Table of Contents

Screenshot

screenshot

Live Demo

Storybook

Storybook

CodeSandbox

CodeSandbox(Uncontrolled)

Install

npm i react-sortable-pane

or

yarn add react-sortable-pane

Usage

Uncontrolled

If you need not to control SortablePane state, please use defaultSize and defaultOrder.

import * as React from 'react';
import { SortablePane, Pane } from 'react-sortable-pane';

export default function SimpleUncontrolledExample() {
  const panes = [0, 1, 2].map(key => (
    <Pane key={key} defaultSize={{ width: '100%', height: 120 }}>
      00{key}
    </Pane>
  ));
  return (
    <div>
      <SortablePane direction="vertical" margin={20} defaultOrder={['0', '1', '2']}>
        {panes}
      </SortablePane>
    </div>
  );
}

Controlled

If you need to control SortablePanestate by yourself, please use size and order.

import * as React from 'react';
import { SortablePane, Pane } from 'react-sortable-pane';

type State = {
  order: string[];
  panes: { [key: string]: { height: number } };
};

export default class SimpleControlledFullExample extends React.Component<{}, State> {
  state = {
    order: ['2', '1', '0'],
    panes: { '0': { height: 100 }, '1': { height: 200 }, '2': { height: 300 } },
  };

  render() {
    const panes = [0, 1, 2].map(key => (
      <Pane key={key} size={{ width: '100%', height: this.state.panes[key].height }}>
        00{key}
      </Pane>
    ));
    return (
      <div>
        <SortablePane
          direction="vertical"
          margin={20}
          order={this.state.order}
          onOrderChange={order => {
            this.setState({ order });
          }}
          onResizeStop={(e, key, dir, ref, d) => {
            this.setState({
              panes: { ...this.state.panes, [key]: { height: this.state.panes[key].height + d.height } },
            });
          }}
        >
          {panes}
        </SortablePane>
      </div>
    );
  }
}

Props

SortablePaneComponent

Props Required Type Default Description
className string undefined Specify className of component.
style React.CssProperties {} Original style of component.
direction 'horizontal' | 'vertical' horizontal The direction is used to set the direction of a component.
order string[] undefined The order is used to control Pane order. If you need not to control Pane state, you can omit this property. (See also, controlled)
defaultOrder string[] undefined The defaultOrder is used to set default Pane order. If you need to control Pane state, please use order property. (See also, uncontrolled)
margin number 0 The margin is used to set the margin between Pane component.
isSortable boolean true The isSortable is used to control whether panes can be dragged or not.
disableEffect boolean false The disableEffect is used to disable floating effect.
dragHandleClassName string undefined The dragHandleClassName is a class name of an element which should handle drag events for panes.
onOrderChange (order: string[]) => void undefined It is called when Pane component order changed. The argument order is array of react element's key.
onResizeStart (e: React.MouseEvent | React.TouchEvent, key: string, dir: PaneResizeDirection) => void undefined It is called when Pane component resize start.
onResize (e: MouseEvent | TouchEvent, key: string, dir: PaneResizeDirection, elementRef: HTMLElement, delta: PaneSize) => void undefined It is called when Pane component resize.
onResizeStop (e: MouseEvent | TouchEvent, key: string, dir: PaneResizeDirection, elementRef: HTMLElement, delta: PaneSize) => void undefined It is called when Pane component resize stop.
onDragStart (e: React.MouseEvent | React.TouchEvent, key: string, elementRef: HTMLElement) => void undefined It is called when Pane component dragging starts.
onDragStop (e: MouseEvent | TouchEvent, key: PaneKey, elementRef: HTMLElement, order: string[]) => void undefined It is called when Pane component dragging stop.

PaneComponent

Props Required Type Default Description
className string undefined Specify className of component.
style React.CssProperties {} Original style of component.
defaultSize { width?: (number | string), height?: (number | string) } auto Specifies the width and height that the dragged item should start at. For example, you can set 300, '300px', 50%.
size { width?: (number | string), height?: (number | string) } auto The size property is used to set the size of the component. For example, you can set 300, '300px', '50%'.
minWidth number | string 10px The minWidth is used to set the minimum width of a Pane component.
minHeight number | string 10px The minHeight is used to set the minimum height of a Pane component.
maxWidth number | string undefined The maxWidth is used to set the maximum width of a Pane component.
maxHeight number | string undefined The maxHeight is used to set the maximum height of a Pane component.
grid [number, number] [1, 1] The maxHeight is used to set the maximum height of a Pane component.
resizable { x: boolean, y: boolean, xy: boolean } { x: true, y: true, xy: true } The resizable is used to set the resizable permission of a component.

Changelog

V1.0.2

  • fix: Fixed a bug, order offset calculation doesn't work properly #203

V1.0.1

  • fix: Add flowtype definition.

V1.0.0

  • chore: Update deps.

V1.0.0-beta.2

  • fix: fixed a min / max size types.

V1.0.0-beta.1

  • fix: fixed a TouchEvent error in IE11.

V1.0.0-beta.0

  • feat: Use TypeScript instead of flowtype.
  • feat: Add defaultSize, defaultOrder, order, size props to control(or uncontrol) SortablePane state.
  • fix: Some tiny bugs.
  • chore: Add some stories.

V0.8.2

  • chore: update deps.

V0.8.1

  • fix: add hysteresis and fix sort position
  • fix: add mouseleave to panes node

V0.8.0

  • fix: remove unused order property.
  • fix: fix position when parent element resized.
  • chore: update deps.

V0.7.1

  • fix: sort, Drag, Resize does not work in Safari #128

V0.7.0

  • chore: update deps (use re-resizable instead of react-resizable-box)

V0.6.8

  • Feature: Add grid props.

V0.6.7

  • Chore: Upgrade dependencies.

V0.6.6

  • Add grid props. (#93)

V0.6.5

  • Update README.

V0.6.4

  • Fix Bug, onResizeStart and onResizeStop not fired.

V0.6.2

  • Use flowtype
  • Use rollup
  • Change callback I/F

V0.5.5

  • Use prop-types package.
  • Fix #56 thanks @avaskys.

V0.5.4

  • Support server side rendering. #50 thanks @lazreg87

V0.5.3

  • Fix componentDidUpdate argument, use this.props instaead of prev.

V0.5.2

  • Use babel-preset-es2015-ie babel-preset-es2015-ie #47 thanks @PabloDiablo

V0.5.1

  • update readme

V0.5.0

  • Fixes a nasty bug
  • Add isResizable props to Pane component
  • Set user-select: none when resizeing or moving.
  • Add zIndex props.
  • update example

V0.4.1

  • Fixes a nasty bug where all Panes could end up sharing the same static style #44 (thanks @ara4n)

V0.4.0

  • Add Object.assign transform plugin
  • Add add-module-exports plugin

V0.3.2

  • Allow strings for width and height. (thanks @lanVS)
  • Add onDragStart and onDragEnd props. (thanks @lanVS)

V0.3.1

  • Add isSortable props. (#34 thanks @lanVS)

V0.3.0

  • Change sort trigger position (#40 thanks @lanVS)

V0.2.12

  • Update react-motion(use "^0.4.3")

V0.2.10, V0.2.11

  • Fix order update bug

V0.2.8

  • Fix size updater bug

V0.2.7

  • Fix size updater bug

V0.2.6

  • Fix order bug
  • Update react-resizable-box(^1.2.0)

V0.2.5

  • Add order props to change order by parent component.
  • Add husky and pre push hook.

V0.2.4

  • update packages to support react v15

V0.2.3

  • update pane size when props.width/height updated.

V0.2.2

  • Fix className bug.

V0.2.1

  • Update resizable box component.

V0.2.0

  • Support pane append and remove.
  • Support vertical mode.
  • Fix pane size calculator.

V0.1.2

  • Add onOrderChange callback.
  • Add disableEffect props.
  • Fix eslint error.

V0.1.1

  • Add onResize callback.

V0.1.0

publised.

License

The MIT License (MIT)

Copyright (c) 2018 @bokuweb

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

react-sortable-pane's People

Contributors

ara4n avatar bokuweb avatar edheltur avatar gbhrdt avatar greenkeeper[bot] avatar haraldox avatar ianvs avatar lazreg87 avatar mergebandit avatar myxious avatar pablodiablo avatar pyreta avatar renovate-bot avatar renovate[bot] avatar rhysd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-sortable-pane's Issues

getting error when running example

warning.js:45 Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method ofPaneStack.warning

Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method ofPaneStack.

added panes in wrong position

Overview of the problem

I'm using react-sortable-pane version [1.0.2]
My browser is: Chrome 69.0.3497.81
I am sure this issue is not a duplicate
https://codesandbox.io/embed/r5x8x63v1n

Description

After init, I try to add panes to the sortablePane, but I find that the added panes are in the wrong place after the second insert.

Steps to Reproduce

  1. In the demo before, just click the add button twice,you will find the problem

Expected behavior

added panes in the right position

Actual behavior

added panes in the wrong position, with a large blank space

My options

actually I find the reason after debugging. In the function below

   getPaneSizeList(): Array<number> {
    const width = this.panes.map((pane: PaneProperty) =>
      Number((pane.ref && (pane.ref as HTMLElement).offsetWidth) || 0),
    );
    const height = this.panes.map((pane: PaneProperty) =>
      Number((pane.ref && (pane.ref as HTMLElement).offsetHeight) || 0),
    );
    return this.isHorizontal() ? width : height;
  }

Seems the function is fine. but let's see the Dom
image
There is a div with className __resizable_base__, which will be involved in the calculation of next pane's position. This lead to the wrong position of the new added panes.
I know the reason but cannot find a way to fix it. Help is needed.

[feature request] show / hide panes

since panes are positioned absolute, we can't show or hide panes with the CSS display: none property, the other panes would remain in place....

@bokuweb I'll try to implement that functionality myself though, don't want you to work for my requirements - i'm sure you have a day job ;)

ReferenceError: window is not defined

Getting reference error when trying to use react-sortable-pane with server-side rendered component, due to eventlisteners

Issue is also present in react-resizable-box dependency

question: how to create two panes always spanning 100% width together

Sorry to span Issues. But I believe this could be helpful for other people too.

I want to create a view with two columns.

The user shall be able to horizontally expand one column. When he does this, the other column should correspondingly reduce width so that both columns together always span 100% of width.

I believe this could be achieved with an onResize handler on SortablePane: on resize a function would reduce the width of the other pane.

I am a bit of a react noob. Could you tell me if this idea is correct and maybe how to set the width of a pane in a function?

Hello!Why I can't run this code,

Hello!Why I can't run this code, when I opened the index.html page, it means that the error is Failed to load the resource: the requested URL on the server can't find

Is it able to use drag handle to drag?

I am wondering if it is possible that only drag the pane with drag handle, so that I may add other mouse event on the pane which will not interfere with the drag.

ETA on vertical panes?

@bokuweb Great component! Was looking all over the web for this, think I struck a gold mine with react-sortable-pane... How / Where did you get the inspiration? :)

Roadmap suggests vertical panes on the horizon, any ETA on that feature? How can I help?

I would also like to split panes when dragged on top of each other...

Issue with rerender / componentWillReceiveProps

So I have a react-sortable-pane on a page with two items. On initialization, they are in order [0,1]. If I swap the order to [1,0], I fire off a dragStop event (orderChanged fires even if I haven't dropped, and that's not desirable). At dragStop I update the order in my app state. Everything is good.

Then I click a button which opens a right-sidebar. This causes my react-sortable-pane to reset to [0,1] order. Within componentWillReceiveProps, if I log this.props.children I see the children in the original order. If I log next.children, I see the children in the desired [1,0] order.

However, because componentWillReceiveProps is checking the arbitrary order prop, the setState({ panes: newPanes }) never gets called. If I manually call this.setSize() from within componentWillReceiveProps, the order of my panes are correct.

The problem I have is - I'm not sure how to fix this properly. Since the internals of pane order simply uses the index in an array, as opposed to something concrete like id, I can't just explicitly update the order.

Do I now have to manage the order myself and pass it in to the SortablePane component? That seems like duplicitous effort - I don't really care - I just want the order to be maintained across re-renders.

Do you have any other thoughts on this?

Cooperate with Storybook

Hi!

Storybook maintainer here. I'm looking around for a solution to a problem, and your package looks close to what we need!

I'm wondering if you'd be interested in cooperating with us and make storybook better by utilizing your package? Since you're using Storybook for your documentation, and this project is actively maintained ( 😍 ) I figured I would just see if you'd be interested in some collaboration?

- ❤️ - Storybook Team -

Demo failing

I was playing around with your demo and it crashed.

I hope my screenshot will help you:
screenshot from 2017-02-14 19 53 50

Resizing first pane when disableEffect=true

I've encountered a strange behavior that only exists when disableEffect={true}. I have vertical panes, and when changing the y size of the first pane, it jumps to the same position as the second pane when releasing the mouse. It then jumps right back to its right spot if the mouse is clicked again. This does not happen when moving the second pane, even after it is rearranged. Take a look at the gif below.

If you have trouble reproducing, I'll try to create a minimal case. I had a look through the source, but couldn't figure out why this is happening. I believe it has to do with the translate3d not updating correctly, but that's as far as I got.

sortable-pane-jumping

Great Panes

I wish I could bring this feature to my table Columns

react-sortable-pane not working on IE

Overview of the problem

I'm using react-sortable-pane for my react project it works fine on chrome (drag and drop and sort functions is working fine) but not on IE

Description

It seems to have a cross browser functionality issue.

Steps to Reproduce

Expected behavior

Actual behavior

Easiest way to achieve full height / width panes?

@bokuweb In The Code of dependancy ‘react-resizable-box’ the string ’px’ is always appended to this.state.height and this.state.width in the component’s render() method

I tried hacking it but fruitless for now ... Any tips on how to achieve this without changes in your packages?

onDragStop fires on mousemove over panes

Overview of the problem

I'm using version 1.0.2
My browser is Google Chrome

Description

The onDragStop callback function is fired every time the mouse moves over a pane rather than just when the mouse is released.

Steps to Reproduce

Expected behavior

onDragStop to only be called when mouse is released after dragging panes.

Actual behavior

onDragStop is fired on mouse move.

onDragEnd bug

Bug

Hello, i report a general bug in the documentation you say :
"Calls when a Pane component is clicked (e.g. to sort it). It will not be executed if isSortable is false. Calls back with (id: number or string)"

Overview of the problem

  • I'm using react-rnd version [0.5.5]
  • My browser is: google chrome
  • I am sure this issue isn't duplicate

Description

onDragEnd is call when you click everywhere in the browser window

Steps to Reproduce

This is your test updated for show my bug

/* eslint-disable */

import React from 'react';
import ReactDOM from 'react-dom';
import { SortablePane, Pane } from './components';

const root = document.querySelector('main');

const style = {
  fontSize: '40px',
  textAlign: 'center',
  borderRadius: '5px',
  padding: '15px',
};

export default class Example extends React.Component {
  constructor(props) {
    super(props);
    this.id = 3;
    this.state = {
      order: [0, 1, 2],
      list: [
        <Pane
          id={1}
          key={1}
          width="100%"
          height={120}
          minWidth={100}
          maxWidth={800}
          minHeight={100}
          style={style}
          className="item"
        >
          <span>no1<br />resize or sort me!!</span>
        </Pane>,
        <Pane
          id={2}
          key={2}
          width={450}
          height={100}
          minWidth={100}
          minHeight={100}
          style={style}
          className="item"
        >
          <span>no2<br />resize or sort me!!</span>
        </Pane>,
        <Pane
          id={3}
          key={3}
          width={470}
          height={110}
          minWidth={100}
          minHeight={100}
          style={style}
          className="item"
        >
          <span>no3<br />resize or sort me!!</span>
        </Pane>,
      ],
    };
    this.add = this.add.bind(this);
    this.remove = this.remove.bind(this);
    this.onResize = this.onResize.bind(this);
  }

  onResize(i) {
    console.log(`resize pane id = ${i}`);
  }

  add() {
    this.state.list.splice(~~(Math.random() * this.state.list.length), 0, (
      <Pane
        id={++this.id}
        key={this.id}
        width={~~(Math.random() * 100) + 350}
        height={~~(Math.random() * 200) + 100}
        minWidth={50}
        minHeight={100}
        style={style}
        className="item"
      >
        <span>no{this.id}<br />resize or sort me!!</span>
      </Pane>
    ));
    this.setState({ list: this.state.list });
  }

  remove() {
    this.state.list.splice(~~(Math.random() * this.state.list.length), 1);
    this.setState({ list: this.state.list });
  }

  onDragEnd = () => {
    console.log('drag end !');
  }

  render() {
    return (
      <div style={{ width: '800px', background: '#ccc' }}>
        <h1>sortable pane</h1>
        <button
          onClick={this.add}
          style={{
            color: '#fff', borderColor: '#fff',
          }}
        >
          Add
        </button>
        <button
          onClick={this.remove}
          style={{
            color: '#fff', borderColor: '#fff', margin: '0 0 30px 10px',
          }}
        >
          Remove
          </button>
        <SortablePane
          direction="vertical"
          margin={20}
          onResize={this.onResize}
          onDragEnd={this.onDragEnd}
          onOrderChange={(pane) => console.dir(pane)}
          onResize={(e, data) => console.dir(data)}
          order={this.state.order}
          isSortable={false}
        >
          {this.state.list}
        </SortablePane>
      </div>
    );
  }
}

ReactDOM.render(<Example />, root);

Expected behavior

Event onDragEnd should not be call when the window is clicked or when isSortable is false

Actual behavior

onDragEvent is call everytime i click on my window and when isSortable is false

FIX

I propose a fix there #66

TouchEvent not working in Firefox or IE

Overview of the problem

I'm using react-sortable-pane version [0.6.5]
My browser is: Firefox, or IE
I am sure this issue is not a duplicate

Description

When I try to drag a pane in Firefox or Internet Explorer, it returns "TouchEvent is not defined" in the console.

Steps to Reproduce

  1. Use react-sortable-pane in Firefox
  2. Try to drag a pane

I believe this is a simple fix, I found this article on stackoverflow that shows the code that needs to be added.

https://stackoverflow.com/questions/27313488/touchevent-not-working-in-firefox-and-other-website-browser

How can interact with inside element

Great component...
but how can interact with specific element inside Pane Component?
For example inside Pane element I have 2 button that execute 2 different actions

Dragging stop resposive while mouse's cursor leave track or window area

Overview of the problem

I'm using react-sortable-pane version [0.7.0]
My browser is: Chrome
OS: Mac OS X

Description

During dragging phase when mouse leave track area or window dragging stopped instead continuously moving like react-draggable do. Is it bug or implementation limits? How to prevent this?

Wrapping a Pane in a custom React.Component prevents sorting

Bug

Overview of the problem

I'm using react-sortable-pane ^1.0.0 and ^1.0.4
My browser is: Tested Chrome and Safari
I am sure this issue is not a duplicate

https://codesandbox.io/s/66367ox0z

Description

Passing a custom React.Component instead of <Pane> as children of <SortablePane> will prevent sorting the Panes.

Steps to Reproduce

I modified the initial example to:

function PaneItem({ key }) {
  return (
    <Pane
      key={key}
      defaultSize={{ width: "100%", height: 120 }}
      style={paneStyle}
    >
      <p style={textStyle}>00{key}</p>
    </Pane>
  );
}

export default function SimpleVertical() {
  const panes = [0, 1, 2].map(key => <PaneItem key={key} />);
  return (
    <div style={{ padding: "10px" }}>
      <SortablePane direction="vertical" margin={20}>
        {panes}
      </SortablePane>
    </div>
  );
}

Expected behavior

You should be able to pass a React.Component that wraps a <Pane>.

Actual behavior

No sorting available. The CSS shows the Panes are position:relative instead of position:absolute

Disable sorting or moving a single pane

Question

Is it possible to fix a single pane in place so it can't be sorted and other panes flow around it?

If not could you lend some insight into maybe creating a PR for it if worth it?

Mix horizontal and vertical panes

@bokuweb: great work on version 0.2.0! :)

now that you got vertical panes implemented (by popular demand ;) how much effort would it be in your opinion, to mix horizontal and vertical panes, i.e. freely drag horizontal to vertical panes and vice versa?

see yellowiscool/LeCadreur as an example (click on flip - top right corner and then drag by color handles)

also kind of like a combined version of STRML/react-grid-layout and its horizontal counterpart cmelion/react-grid-layout

or even gridster.js

Thanks for your feedback! I checked out your github repos as well as blog and you have very interesting projects ... I can feel this component becoming big!

Question regarding the pane order prop.

Hi,

I'm using version 0.6.8.
I have modified the example with the controllers to dynamically add and delete panes.

Here's one thing I don't understand, unless I'm doing something wrong:

  1. The "order" value, which is provided when the panes are being initialized in the stories example doesn't seem to do anything and never seems to change when I log it in the onDragStop and onOrderChange.

...this.state = { order: [0, 1, 2], list: [0, 1, 2].map(id => (...

  1. What's the use of the order prop in the pane, if you look at the demo log you'll also see that the array which is being logged in onDragStop has the proper order, but the order values never change, they actually represent the position of the pane at the time it was created.

Is the order prop there to represent the chronological order, not the current one and I have to get the current one programatically from the current array order?

BR
Daniel

Reorder in grid?

I have an array of images, each represented by a pane, which I want to lay out in a floating grid, and then allow reordering by dragging left/right and also up/down. Is this possible in the current implementation? If not, will you consider this a worthy feature?

onDragStop event is bubbled up to window, instead of being tied to parent element

Overview of the problem

I'm using react-sortable-pane version [0.6.5]
My browser is: Google Chrome
I am sure this issue is not a duplicate?

Description

onDragStop event is bubbled up to the window for whatever reason instead of being tied to a parent element. This causes it to be called whenever someone clicks anywhere on the page. I believe it's the same for multiple other methods.

A thing to note is that I'm also using the drag handler. Not sure if there's a bug with that rather than the event itself.

Steps to Reproduce

  1. Add onDragStop to your SortablePane component
  2. console.log(panes)
  3. Check console

Expected behavior

It should log the changed panes after you stop dragging.

Actual behavior

It logs the changed panes everytime you click on the page, regardless if you click on the handle or element.

isSortable="false" prop not working

I've tried a few different things, but can't seem to get isSortable="false" to work. The panes can still be dragged as before.

Am I doing something wrong or is this a bug?

Thanks^^

render() {
    return (
        <SortablePane
          isSortable="false" /* <-- not working, also does not work on individual panes */
          direction="vertical"
          margin={3}
          onResize={(id, dir, size, rect) => null}
          onOrderChange={(panes) => null}
          disableEffect="true" /* <-- this does work :)  */
        >
          <Pane
            id={1}
            key={1}
            width={"99%"}
            height={25}
            style={this.state.styles}
          >
            こんにちは
          </Pane>
          <Pane
            id={2}
            key={2}
            width={"99%"}
            height={500}
            style={this.state.styles}
          >
            Bonjour
          </Pane>
          <Pane
            id={3}
            key={3}
            width={"99%"}
            height={"200"}
            style={this.state.styles}
          >
            Hello
          </Pane>
        </SortablePane>
    );
  }

How add key name into array what we get in orderChange?

in orderChange I get next

[
{ 
   height:252,
   id:9, 
   order: 1,
   width: 148,
>>want here add parameter  - name: 'some name from tag pane ', 
}
{ 
   height:252,
   id:12, 
   order: 2,
   width: 148,
}
{...}
]

my Pane

<Pane 	data-id =	{key.name} 
										key =		{index} 
										className =	'column'
									        isResizable =   {{x: false, y: false, xy:false}}
									        name =            {key.name}
										width =		{148} 
										height =	        '100%'
										id =		        {key.id}>
													<div className='table_head'>
														{language_variant[key.name]}
													</div>
													<div className='table_content'>
													</div>
								
										</Pane>

setting min-height on a pane?

I'm using a text area in the panes. When expanding the text area, the pane does not resize. Setting minHeight on the pane element makes the pane resize in correlation to the text area if I did inspect element and changed the computed css thru firebug/dev tools

[Feature request] Fit to the parent container

First of all, pretty neat implementation! Probably this feature request should be implemented as another component, I think usually we don't want horizontal scrolling or the elements to go out of the visible area. So, it would be great if by dragging an element edge, it would resize the next one as well to keep them fitted into the parent container. I guess it would be useful for your example as well.

Crash on touch events

Hi,

thanks for this amazing framework. I like to use it, but for mobile purposes it seems to crash always on touch events.

Steps to reproduce:

  1. Go to https://codesandbox.io/s/5kn43wl9y4
  2. Switch into your browsers developer mode with mobile preview
  3. Try to drag elements
  4. Observe the error

screen shot 2018-07-22 at 17 26 11

Question: Would you are going to support touch events in the future or not? Maybe it would be best to tell the user of the framework, that touch is not supported and catch the error? Otherwise, I would love to have touch events enabled.

probleme with direction='vertical'

Hi I'm using "react": "^15.6.1".
when setting direction to 'horizontal' the list are normal but when set it to vertical all panes come stacked on top of each other i'm wondring if it is a bug or the code need to be fixed, the code i used is the one provided in the example of the repostrie, code:

<SortablePane direction="vertical" margin={20}>
   <Pane id={0} key={0} width={120} height="100%">
     <p>0</p>
   </Pane>
   <Pane id={1} key={1} width={120} height="100%">
     <p>1</p>
   </Pane>
 </SortablePane>

changing size breaks order

If you change the size of any child then sizePropsUpdated is set to true, then setSize is called, which ignore the order from props

isResizable props not working

I made same component exactly same as example code
and just edit "isResizable" props like below code.

<Pane
                    width={200}
                    height={500}
                    style={style}
                    id="A"
                    isResizable={{ x:false, y:false, xy:false }}
                    >

but component still resizable.
I used version 0.2.3

width / height do not change via props

hi there again @bokuweb, i'm not done making trouble! :)

if i've read your code correctly, the Pane component is not stateless, i.e. always same behavior with same props because when I change props width or height on <Pane>, box dimensions do not change but stay at the initial sizes...

Is that behavior on purpose? I would need to support resizing the box programmatically as well (not only via the resizers...)

As always, Any feedback is appreciated! ;) Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.