Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added onDragEnd event #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ menuEditor.onClickEdit((event) => {
console.log(itemData);
menuEditor.edit(event.item); // set the item in edit mode
});

menuEditor.ondragEnd((event) => {
let output = editor.getString();
console.log(output);
// add logic here
});

```

### Setting the data
Expand Down
3 changes: 3 additions & 0 deletions lib/MenuEditor.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Sortable from "sortablejs";
import { Item } from "./Item";
import { NestedItemData, Itemlistener, ItemDataset, ItemData, MenuEditorOptions } from "./types";
import { ElementItem } from "./ElementItem";
Expand All @@ -6,6 +7,7 @@ export default class MenuEditor {
private currentItem;
protected listenerDeleteButton: Itemlistener;
protected listenerEditButton: Itemlistener;
protected listenerDragEnd: (_evt: Sortable.SortableEvent) => void;
protected sortableClassname: string;
protected options: MenuEditorOptions;
constructor(id: string, options?: MenuEditorOptions);
Expand All @@ -17,6 +19,7 @@ export default class MenuEditor {
protected htmlToJson(element: HTMLElement): ItemData[];
onClickEdit(listener: Itemlistener): void;
onClickDelete(listener: Itemlistener): void;
onDragEnd(listener: (evt: Sortable.SortableEvent) => void): void;
empty(): void;
mount(): void;
protected makeItSortable(): void;
Expand Down
2 changes: 1 addition & 1 deletion lib/css/styles.css

Large diffs are not rendered by default.

Loading