Skip to content

Custom Element with sortable list, that uses CSS flexbox

Notifications You must be signed in to change notification settings

tomalec/sortable-flexbox-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<tomalec-sortable-list>

<tomalec-sortable-list> is a Custom Element with sortable list, that uses CSS flexbox.

Maintained by Tomek Wytrębowicz.

Demo

Check it live.

Advanced examples:

Install

Install the component using Bower:

$ bower install tomalec-sortable-list --save

Usage

  1. Import Web Components' polyfill, if needed:

    <script src="bower_components/webcomponentsjs/webcomponents.js"></script>
  2. Import Custom Element:

    <link rel="import" href="bower_components/tomalec-sortable-list/src/tomalec-sortable-list.html">
  3. Start using it!

    <tomalec-sortable-list>
    	<li>zero</li>
    	<li>one</li>
    	<li>two</li>
    </tomalec-sortable-list>

Please note, that <style>, <template>, and text nodes will not be sortable.

tomalec-sortable-body is no longer supported with Polymer 1.2

Options/Attributes

Attribute Options Default Description
disabled boolean false If set to true none of elements will be draggable.
order string "1,...,n" Coma separated sequence of elements' order. By default as is in HTML.
Please note that this is NOT a list of sorted indexes, rather a map where the key is index from HTML, and value is CSS order - position on screen.

Properties

Property Type Description
disabled boolean Is dragging disabled?
order string Coma separated sequence of elements' order. See above.

Events

For child nodes:

Event Name event.detail Description
change Triggered after every order change.
		| *String* `from`			| Previous order
		| *String* `to`				| New order
		| *Array*  `orderArray`		| New order as array

move | | Triggered after every item move. | String from | Previous place in order, | String to | New place in order, | Array orderArray | New order as array, | EventTarget item | DOM Node that was moved.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

For detailed changelog, check Releases.

License

MIT License © Tomek Wytrebowicz

About

Custom Element with sortable list, that uses CSS flexbox

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •