Skip to content

Commit 31f1acd

Browse files
committed
Adjust example for version 0.2.1.
1 parent 1c9410d commit 31f1acd

File tree

7 files changed

+28
-220
lines changed

7 files changed

+28
-220
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ Changelog
1212
* SortableEvent now carries information about the original group of the
1313
dragged element and the new group it was dragged to. This enables
1414
uninstalling in the previous group and installing in the new group.
15-
* Other minor improvements in Sortable.
15+
* Other minor improvements in Sortable.
16+
17+
## Version 0.2.1 (2013-06-17) ##
18+
* Fix Issue #6: Bug in Firefox when dragging over nested elements
19+
* Fix Issue #1: overClass (.dnd-over) stays after drag ended
20+
* Fix Issue #4: Support any HTML Element as drag image
21+
* Fix Issue #5: Always use Drag Image Polyfill for IE9 drags

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ HTML5 Drag and Drop for Dart
44
Helper library to simplify **Native HTML5 Drag and Drop** in Dart.
55

66
## Features ##
7-
* Make any HTML Element `Draggable`.
8-
* Create `Dropzone`s and connect them with `Draggable`s.
9-
* Sortable (similar to jQuery UI Sortable).
7+
* Make any HTML Element `draggable`.
8+
* Create `dropzone`s and connect them with `draggable`s.
9+
* `Sortable` (similar to jQuery UI Sortable).
1010
* Uses fast native HTML5 Drag and Drop of the browser.
11-
* Same functionality and API for IE9+, Firefox, Chrome. (Safari and Opera have
12-
not been tested yet, let me know if it works).
11+
* Same functionality and API for IE9+, Firefox, Chrome and Safari.
1312

1413
## Demo ##
1514
See [HTML5 Drag and Drop in action](http://edu.makery.ch/projects/dart-html5-drag-and-drop) (with code examples).
@@ -54,7 +53,7 @@ I'd like to thank the people who kindly helped me with their answers or put
5453
some tutorial or code examples online. They've already contributed to this
5554
project.
5655

57-
If you'd like to contribute, you're welcome to file issues or
56+
If you'd like to contribute, you're welcome to report issues or
5857
[fork](https://help.github.com/articles/fork-a-repo) my
5958
[repository on GitHub](https://github.com/marcojakob/dart-html5-dnd).
6059

example/codeblocks.dart

Lines changed: 1 addition & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ codeblockDragImages(Element section) {
192192
</div>
193193
<div class="dragme three">
194194
custom drawn canvas
195-
</div>
196-
<div class="dragme four">
197-
Always uses Polyfill
198195
</div>
199196
''',
200197
// CSS
@@ -237,17 +234,10 @@ DraggableGroup dragGroupThree = new DraggableGroup()
237234
return new DragImage(canvasImage, 0, 0);
238235
};
239236
240-
DraggableGroup dragGroupFour = new DraggableGroup()
241-
..install(query('#drag-images .four'))
242-
..alwaysUseDragImagePolyfill = true
243-
..dragImageFunction = (Element draggable) {
244-
return new DragImage(canvasImage, 0, 0);
245-
};
246-
247237
// Install dropzone.
248238
DropzoneGroup dropGroup = new DropzoneGroup()
249239
..install(query('#drag-images .dropzone'))
250-
..accept.addAll([dragGroupOne, dragGroupTwo, dragGroupThree, dragGroupFour]);
240+
..accept.addAll([dragGroupOne, dragGroupTwo, dragGroupThree]);
251241
''');
252242
}
253243

@@ -528,89 +518,3 @@ sortGroup1.accept.addAll([sortGroup1, sortGroup2]);
528518
sortGroup2.accept.addAll([sortGroup1, sortGroup2]);
529519
''');
530520
}
531-
532-
codeblockDraggableSortable(Element section) {
533-
_createCodeblock(section,
534-
// HTML
535-
'''
536-
<ul class="example-box group1">
537-
<li>Item 1</li>
538-
<li>Item 2</li>
539-
<li>Item 3</li>
540-
<li>Item 4</li>
541-
<li>Item 5</li>
542-
<li>Item 6</li>
543-
</ul>
544-
<ul class="example-box group2">
545-
<li class="empty">Empty list!</li>
546-
</ul>
547-
''',
548-
// CSS
549-
'''
550-
#draggable-sortable {
551-
height: 250px;
552-
}
553-
554-
#draggable-sortable .dnd-placeholder {
555-
border: 1px dashed #CCC;
556-
background: none;
557-
}
558-
559-
#draggable-sortable .dnd-dragging {
560-
opacity: 0.5;
561-
}
562-
563-
#draggable-sortable .dnd-over {
564-
background: #d387ca;
565-
}
566-
567-
#draggable-sortable .group1 li {
568-
cursor: move;
569-
}
570-
571-
#draggable-sortable .group1 {
572-
float: left;
573-
width: 150px;
574-
}
575-
576-
#draggable-sortable .group2 {
577-
float: right;
578-
width: 150px;
579-
}
580-
581-
#draggable-sortable .group2 .empty {
582-
border: 1px dashed #CCC;
583-
color: #333;
584-
}
585-
''',
586-
// Dart
587-
'''
588-
DraggableGroup dragGroup = new DraggableGroup()
589-
..installAll(queryAll('#draggable-sortable .group1 li'));
590-
591-
// Create sortable group with initially no installed elements.
592-
SortableGroup sortGroup = new SortableGroup()
593-
..onSortUpdate.listen((SortableEvent event) {
594-
event.originalGroup.uninstall(event.draggable);
595-
event.newGroup.install(event.draggable);
596-
});
597-
sortGroup.accept.addAll([dragGroup, sortGroup]);
598-
599-
LIElement emptyItem = query('#draggable-sortable .group2 .empty');
600-
601-
// Install an empty item as a dropzone no element is in the list.
602-
DropzoneGroup emptyListDropzone = new DropzoneGroup()
603-
..install(emptyItem)
604-
..accept.add(dragGroup)
605-
..onDrop.listen((DropzoneEvent event) {
606-
// Hide empty item.
607-
emptyItem.style.display = 'none';
608-
609-
// Uninstall in old group and install in new group.
610-
dragGroup.uninstall(event.draggable);
611-
event.draggable.remove();
612-
sortGroup.install(event.draggable);
613-
query('#draggable-sortable .group2').children.add(event.draggable);
614-
});
615-
''');
616-
}

example/html5_dnd_example.css

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -384,43 +384,4 @@ h2 {
384384
#sortable-two-groups .group2 {
385385
float: right;
386386
width: 150px;
387-
}
388-
389-
/* --------------------------------------------------------------------------
390-
* Section: draggable-sortable
391-
* ------------------------------------------------------------------------*/
392-
#draggable-sortable {
393-
height: 250px;
394-
}
395-
396-
#draggable-sortable .dnd-placeholder {
397-
border: 1px dashed #CCC;
398-
background: none;
399-
}
400-
401-
#draggable-sortable .dnd-dragging {
402-
opacity: 0.5;
403-
}
404-
405-
#draggable-sortable .dnd-over {
406-
background: #d387ca;
407-
}
408-
409-
#draggable-sortable .group1 li {
410-
cursor: move;
411-
}
412-
413-
#draggable-sortable .group1 {
414-
float: left;
415-
width: 150px;
416-
}
417-
418-
#draggable-sortable .group2 {
419-
float: right;
420-
width: 150px;
421-
}
422-
423-
#draggable-sortable .group2 .empty {
424-
border: 1px dashed #CCC;
425-
color: #333;
426387
}

example/html5_dnd_example.dart

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ part 'codeblocks.dart';
1212

1313
main() {
1414
// Uncomment to enable logging.
15-
Logger.root.onRecord.listen(new PrintHandler().call);
16-
Logger.root.level = Level.FINEST;
15+
// Logger.root.onRecord.listen(new PrintHandler().call);
16+
// Logger.root.level = Level.FINEST;
1717

1818
// Drag and Drop
1919
sectionDraggableAndDropzone();
@@ -28,7 +28,6 @@ main() {
2828
sectionSortableListExclude();
2929
sectionSortableListHandles();
3030
sectionSortableTwoGroups();
31-
sectionDraggableSortable();
3231

3332
installCodeblockTabs();
3433
}
@@ -44,7 +43,6 @@ installCodeblockTabs() {
4443
codeblockSortableListExclude(query('#sortable-list-exclude'));
4544
codeblockSortableListHandles(query('#sortable-list-handles'));
4645
codeblockSortableTwoGroups(query('#sortable-two-groups'));
47-
codeblockDraggableSortable(query('#draggable-sortable'));
4846

4947
List<AnchorElement> tabLinks = queryAll('.example-code .menu li a');
5048
for (AnchorElement link in tabLinks) {
@@ -149,17 +147,10 @@ sectionDragImages() {
149147
return new DragImage(canvasImage, 0, 0);
150148
};
151149

152-
DraggableGroup dragGroupFour = new DraggableGroup()
153-
..install(query('#drag-images .four'))
154-
..alwaysUseDragImagePolyfill = true
155-
..dragImageFunction = (Element draggable) {
156-
return new DragImage(canvasImage, 0, 0);
157-
};
158-
159150
// Install dropzone.
160151
DropzoneGroup dropGroup = new DropzoneGroup()
161152
..install(query('#drag-images .dropzone'))
162-
..accept.addAll([dragGroupOne, dragGroupTwo, dragGroupThree, dragGroupFour]);
153+
..accept.addAll([dragGroupOne, dragGroupTwo, dragGroupThree]);
163154
}
164155

165156
sectionNestedElements() {
@@ -254,34 +245,4 @@ sectionSortableTwoGroups() {
254245
// Only accept elements from this section.
255246
sortGroup1.accept.addAll([sortGroup1, sortGroup2]);
256247
sortGroup2.accept.addAll([sortGroup1, sortGroup2]);
257-
}
258-
259-
sectionDraggableSortable() {
260-
DraggableGroup dragGroup = new DraggableGroup()
261-
..installAll(queryAll('#draggable-sortable .group1 li'));
262-
263-
// Create sortable group with initially no installed elements.
264-
SortableGroup sortGroup = new SortableGroup()
265-
..onSortUpdate.listen((SortableEvent event) {
266-
event.originalGroup.uninstall(event.draggable);
267-
event.newGroup.install(event.draggable);
268-
});
269-
sortGroup.accept.addAll([dragGroup, sortGroup]);
270-
271-
LIElement emptyItem = query('#draggable-sortable .group2 .empty');
272-
273-
// Install an empty item as a dropzone no element is in the list.
274-
DropzoneGroup emptyListDropzone = new DropzoneGroup()
275-
..install(emptyItem)
276-
..accept.add(dragGroup)
277-
..onDrop.listen((DropzoneEvent event) {
278-
// Hide empty item.
279-
emptyItem.style.display = 'none';
280-
281-
// Uninstall in old group and install in new group.
282-
dragGroup.uninstall(event.draggable);
283-
event.draggable.remove();
284-
sortGroup.install(event.draggable);
285-
query('#draggable-sortable .group2').children.add(event.draggable);
286-
});
287248
}

example/html5_dnd_example.html

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ <h1>Dart HTML5 Drag and Drop</h1>
4545
</li>
4646
</ul>
4747
</p>
48+
<p>You are welcome to contribute by reporting an
49+
<a href="https://github.com/marcojakob/dart-html5-dnd/issues">Issue</a>
50+
or <a href="https://help.github.com/articles/fork-a-repo">forking the repository<a/>.
51+
</p>
4852
</div>
4953

5054
<h2>Draggable and Dropzone</h2>
@@ -61,15 +65,15 @@ <h2>Draggable and Dropzone</h2>
6165

6266
<h2>Dragging Divs</h2>
6367
<p>
64-
All HTML elements with the `draggable="true"` attribute can be dragged -
68+
All HTML elements with the <em>draggable="true"</em> attribute can be dragged -
6569
well...almost. Internet Explorer 9 does not support this attribute and
66-
thus by default only links and images are draggable in IE9. With a decent
70+
thus by default only links and images are draggable in IE9. With a
6771
<a href="http://stackoverflow.com/a/8986075/862411">workaround</a>, we
6872
can also tell IE9 to drag anything. Try the following example in IE9.
6973
</p>
7074
<p>
71-
<strong>Note:</strong> The `draggable="true"` attribute is automatically
72-
added by the `Draggable` class, so there is no need to set it in HTML.
75+
<strong>Note:</strong> The <em>draggable="true"</em> attribute is automatically
76+
added to draggables, so there is no need to set it in HTML.
7377
</p>
7478
<div id="dragging-divs" class="example-container">
7579
<div class="dragme">
@@ -98,8 +102,7 @@ <h2>Drop Effects</h2>
98102
<h2>Custom Drag Images</h2>
99103
<p>
100104
That was a tough one to make work cross-browser! IE9 and IE10 do not
101-
support setting a custom drag image (as other modern browsers do). IE
102-
always creates a drag image from the element that the user picks up.
105+
support setting a custom drag image (as other modern browsers do).
103106
</p>
104107
<p>
105108
So I had to implement a <strong>polyfill</strong> that draws a custom
@@ -109,12 +112,7 @@ <h2>Custom Drag Images</h2>
109112
default image does not show, 2. draw the custom image, 3. ensure the mouse
110113
events are passed through to the layer underneath the drag image... more
111114
info in the source).
112-
</p>
113-
<p>
114-
<strong>Note:</strong> The polyfill for drag images is automatically used
115-
if the browser does not support it. But you can use the polyfill for any
116-
browser by setting `alwaysUseDragImagePolyfill = true` on the `Draggable`.
117-
</p>
115+
</p>
118116
<div id="drag-images" class="example-container">
119117
<div class="dropzone example-box">
120118
Drag here!
@@ -128,9 +126,6 @@ <h2>Custom Drag Images</h2>
128126
<div class="dragme three">
129127
custom drawn canvas
130128
</div>
131-
<div class="dragme four">
132-
Always uses Polyfill
133-
</div>
134129
</div>
135130

136131
<h2>Dropping on Nested Elements</h2>
@@ -245,28 +240,10 @@ <h2>Two Sortable Groups</h2>
245240
<li class="other">Item 6</li>
246241
</ul>
247242
</div>
248-
249-
<h2>Draggables and a Sortable Group</h2>
250-
<p>
251-
The draggable elements on the left can be dragged into the sortable group
252-
on the right.
253-
</p>
254-
<div id="draggable-sortable" class="example-container">
255-
<ul class="example-box group1">
256-
<li>Item 1</li>
257-
<li>Item 2</li>
258-
<li>Item 3</li>
259-
<li>Item 4</li>
260-
<li>Item 5</li>
261-
<li>Item 6</li>
262-
</ul>
263-
<ul class="example-box group2">
264-
<li class="empty">Empty list!</li>
265-
</ul>
266-
</div>
267243
</article>
268244

269245
<script type="application/dart" src="html5_dnd_example.dart"></script>
270246
<script src="packages/browser/dart.js"></script>
247+
<script src="packages/browser/interop.js"></script>
271248
</body>
272249
</html>

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: html5_dnd
2-
version: 0.2.0
2+
version: 0.2.1
33
author: Marco Jakob <[email protected]>
44
description: HTML5 Drag and Drop
55
homepage: https://github.com/marcojakob/dart-html5-dnd

0 commit comments

Comments
 (0)