Git Product home page Git Product logo

react-sortable-hoc's People

Contributors

ahmedelgabri avatar alastairtaft avatar amje avatar anaumov avatar asamiller avatar binary1101 avatar bradwestfall avatar brianreavis avatar bvaughn avatar childishdanbino avatar chrisvasz avatar clauderic avatar deadheadrussell avatar flash-gordon avatar frontendphil avatar funnel-mark avatar jedwards1211 avatar jschlieber avatar krisl avatar levithomason avatar nervetattoo avatar neurostep avatar oliverjash avatar ralf-strehle avatar ricardo-marques avatar richmeij avatar ryanbertrand avatar smenigat avatar v0lkan avatar zaygraveyard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-sortable-hoc's Issues

Picked up item doesn't take into account scrolling

We need to make sure dragging works when any of the lists are scrolled. This includes both the list you are dragging from, dragging over and dropping into. It looks like it happens with or without a virtualized list.

image

Gist

How the elements are animating to make space for item being dragged

@jdbence I was trying to integrate your changes with my one (which are about handling collisions or merge of items). I am almost done, but it is not working as expected when I am dropping an item for the first time into different list. It seems this animation, when an item is moved into different list, is not handled via animateNodes method. So, I am looking for the place where this is being handled. Is it simply because you are adding the item into the target list and React rendering doing the rest of the stuff? I am not able to understand what I am missing here.

Edit: Apologies to create an issue for a question. However, I didn't find any other way to contact you. :)

Two Scroll Containers

Is it possible to have two scroll containers?

For instance like Trello, You have a List and in that list you have Tasks. Now you'll want the List container to be scrollable vertically so you can drag the tasks up and down the List container. You'll also want to drag to another list but if those lists stretch past the parent containers width there's no way to drag the tasks to the other lists off the screen. You'd have to drag the task to the last visible List and then manually scroll the parent container horizontally and then pick the task back up and drag it to the desired list.

If not I can do it myself, but I thought I'd ask before I do.

Elements set to visibility: 'hidden', opactiy: 0 and index is not being updated when dragged

When I drag an item within the same list it will save it on the first drag but since the index didn't update, on the following dragging events it will move all of the items at once and there are empty spaces because it thinks its moving it as if it were still in its last position.

When moving to another list it hides the sortable element with the same index and since the indexes are not updating the element with the same index stays hidden.

Below is my component ( I removed alot of code but this is the main sorting part of the code)
ListWrapper is the same as the ListWrapper component from your src/stories/index.js file.

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import List from '../List';
import { default as Item } from '../Item';
import { SortableContainer, SortableElement, DragLayer } from 'react-sortable-hoc';
import ListWrapper from './ListWrapper';

const SortableItem = SortableElement(Item)
const SortableList = SortableContainer(List, { withRef: true })

class Container extends Component {
    constructor(props) {
        this.createLists = this.createLists.bind(this)
        this.state = { lists: [] }
    }

    createLists() {
            const createItems = (data) => {
                                let items= []
                                let i = 0
                                for(let prop in data) {
                                    items.push(
                                        <SortableItem
                                            key={ `task-${prop}-${data[prop].name}` }
                                            index={ i }
                                            pressDelay={ 100 }
                                            title={ data[prop].name } 
                                            description={ data[prop].description } />
                                    )
                                    i++
                                }
                                return items
            }

            let lists= [];
            const dragLayer = new DragLayer();

            for (let key in data) {
                lsits.push(<ListWrapper
                                component={SortableList}  
                                key={ key } 
                                pressDelay={ 100 }
                                title={ humanize(key) }
                                items={ createItems(data[key].items) }
                                dragLayer={ dragLayer }
                                getContainer={ wrappedInstance => ReactDOM.findDOMNode(wrappedInstance).children[1] }
                            />
                            )
            }

            this.setState({ lists: lists}) 
    }

    componentWillMount() {
        this.createLists()
    }

    render() {
            return (
                <div>	
                    <h1>{ this.props.name }</h1>
                    <div>
                       { this.state.lists}
                    </div>
                </div>
            )
        }
}

Dragging an item into a list that contains no items.

If you drag an item from one list into another and the destination list is empty to begin with it throws this error.

Uncaught TypeError: Cannot read property 'slice' of null
    at arrayInsert 
    at onSortSwap 
    at _class._this.handleSortSwap 
    at onSortEnd 
    at _class._this.handleSortEnd 
    at DragLayer.updateTargetContainer 
    at DragLayer.handleSortMove 

Uncaught TypeError: Cannot read property 'item' of null
    at DragLayer.updateTargetContainer 
    at DragLayer.handleSortMove 

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.