Skip to content

Commit

Permalink
Optimize dragndrop of first level elements
Browse files Browse the repository at this point in the history
These elements always ever move vertically.
  • Loading branch information
tvdeyen committed Dec 19, 2023
1 parent f436e5c commit 17d0282
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/javascript/alchemy_admin/sortable_elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function onEnd() {
)
}

function createSortable(element) {
function createSortable(element, options = {}) {
const group = {
name: element.dataset.elementName,
put(to, _from, item) {
Expand All @@ -55,6 +55,7 @@ function createSortable(element) {
}
new Sortable(element, {
...SORTABLE_OPTIONS,
...options,
onStart,
onSort,
onEnd,
Expand All @@ -66,7 +67,9 @@ export default function SortableElements(selector) {
if (selector == null) {
selector = "#element_area .sortable-elements"
}
const sortable_areas = document.querySelectorAll(selector)
const sortable_areas = document.querySelectorAll(selector, {
direction: "vertical"
})

sortable_areas.forEach((element) => {
createSortable(element)
Expand Down

0 comments on commit 17d0282

Please sign in to comment.