GithubHelp home page GithubHelp logo

cyclejs-community / cyclejs-sortable Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 7.0 1.67 MB

Makes all children of a selected component sortable

License: MIT License

TypeScript 100.00%
drag-and-drop cyclejs

cyclejs-sortable's Introduction

cyclejs-sortable

Makes all children of a selected component sortable

Github Repo: https://github.com/cyclejs-community/cyclejs-sortable

Full documentation: https://cyclejs-community.github.io/cyclejs-sortable/

NPM: https://www.npmjs.com/package/cyclejs-sortable

Examples

You can check out live versions of the examples here:

Installation

npm install --save cyclejs-sortable

Basic Usage

For more information see the examples

const main = isolate(
    makeSortable(Component, { itemSelector: 'div > div' }),
    'myScope'
);

function Component(sources)
{
    return {
        DOM: xs.of(div([
            div(['one']),
            div(['two']),
            div(['three']),
            div(['four'])
        ]));
    }
}

cyclejs-sortable's People

Contributors

jvanbruegge avatar ntilwalli avatar olpeh avatar

Stargazers

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

Watchers

 avatar  avatar

cyclejs-sortable's Issues

restrictMovementArea didn't seem to work

If you take the example in cyclejs/examples/http-search-github, I tried to add this library by including this line:

  // Convert the stream of HTTP responses to virtual DOM elements.
  const vtree$ = sources.HTTP.select('github')
    .flatten()
    .map(res => res.body.items)
    .startWith([])
    .map(results =>
      div([
        label('.label', 'Search:'),
        input('.field', {attrs: {type: 'text'}}),
        hr(),
        ul('.search-results', results.map(result =>
          li('.search-result', [
            a({attrs: {href: result.html_url}}, result.name)
          ])
        ))
      ])
-   );
+   ).compose(makeSortable(sources.DOM, { restrictMovementArea: '.search-results' }));

Apparently it added .x-sortable-item to all of the elements under the div. I would expect only li elements under ul.search-results would get the .x-sortable-item.

package.json "main" broken

"main": "makeSortable.js" should be "main": "build/makeSortable.js" I believe. Otherwise, import {makeSortable} from 'cyclejs-sortable' won't work as the bundler can't find cyclejs-sortable

Link to hosted working examples

Would it be possible to host some examples for users to play with?

Thanks! Looking forward to to trying this library

Olly

Allow for multiple stream libraries

I have to use adapt, but I'm not completely sure if xs.fromObservable just works with all stream libs or if I have to do something else for the incoming stream

Maybe @staltz can help here?

Add Update event on mouseup

Fingure out how to notify the user of makeSortable that the order changed.
Ideas:

  • Dispatch custom event on element
  • Add callback to options

Bug when moving an item too quickly

This works because I did it slowly:

slow

This doesn't because I moved it quickly:

fast

PS: overall I'm loving the idea of this library and the prospect of making any UI easily sortable with one line of code. I just think it needs some polishing first.

Touch support

Hi there, do you have any plans to support touch devices? Thanks!

Losing mouseleave when mouse leaves viewport

I tested in Firefox desktop and if I drag and the mouse goes out of the viewport (e.g. if it goes near the address bar) then my mouseleave isn't computed anymore and it's stuck with dragging.

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.