Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Conversation

@yotamberk
Copy link
Member

closes #2180, #1881


var items = document.querySelectorAll('.items .item');

items.forEach(function(item) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work! querySelectorAllreturns a NodeList and not an array. This could be fixed by:

var items = Array.prototype.slice.call(document.querySelectorAll('.items .item'));

but that's not beautiful.
Better use an old style for loop instead the forEach!

<div>
<h3>Items:</h3>
<ul class="items">
<li draggable="true" class="item">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ".items" should get a style with a max-width, a border, a drag-cursor and maybe a icon that shows that they can be dragged (something like "≣")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added fa fa-bars icon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irrelevant now... Using pure CSS

@mojoaxel mojoaxel added this to the Minor Release v4.17 milestone Oct 28, 2016
Copy link
Member

@mojoaxel mojoaxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the changes in lib/timeline/component/ItemSet.js ??

<script src="../../googleAnalytics.js"></script>

<style type="text/css">
li {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These generic styles can break somebodies application if copied without thinking. Better write: li.item {

margin-bottom: 5px;
padding: 5px 12px;
}
i {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could something like this, without needing FontAwesome at all :-)

li.item:before {
    content: "≣";
    font-family: Arial, sans-serif;
    display: inline-block;
    font-size: inherit;
    cursor: move;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed... Done!

@yotamberk
Copy link
Member Author

@mojoaxel There were some changes that had to be done there to support different kind of drop handlers (adding an item according to the item type in the drops' event data)

Copy link
Member

@mojoaxel mojoaxel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing that I noticed: It would be nice if the newly added item would automatically be in the "edit" state (yellow), so you could move it just after dragging it onto the timeline. What do you think? Could that be achieved easily?

@@ -0,0 +1,130 @@
<!DOCTYPE HTML>
<html>
<head>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I just noticed that the UTF-8 coding is missing: <meta charset="utf-8"/>
Without it the unicode-symbols are broken:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@yotamberk
Copy link
Member Author

Another thing that I noticed: It would be nice if the newly added item would automatically be in the "edit" state (yellow), so you could move it just after dragging it onto the timeline. What do you think? Could that be achieved easily?

done!

@mojoaxel mojoaxel merged commit dd324da into visjs:develop Oct 29, 2016
@mojoaxel
Copy link
Member

@yotamberk Thank you so much! That's really a great new feature!

@yotamberk yotamberk deleted the drag-and-drop branch March 4, 2017 19:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants