Frontend Page - Configure MenuConfig: Difference between revisions
Jump to navigation
Jump to search
(→OnDrag) |
(→OnDrag) |
||
Line 44: | Line 44: | ||
dragable | dragable | ||
onDragStart={(e) => { | onDragStart={(e) => { | ||
dragStartRowIndex.current = rowIndex; | dragStartRowIndex.current = rowIndex; //set value when clicked element | ||
dragPassRowIndex.current = null; | dragPassRowIndex.current = null; | ||
setdragnamerow("row"); | setdragnamerow("row"); | ||
Line 51: | Line 51: | ||
if (dragnamerow === "row") { | if (dragnamerow === "row") { | ||
dragPassRowIndex.current = rowIndex; | dragPassRowIndex.current = rowIndex; | ||
setDragPassRowIndexState(rowIndex) | setDragPassRowIndexState(rowIndex); | ||
} | } | ||
}} | }} | ||
Line 62: | Line 62: | ||
* onDragEnter : when you passed element | * onDragEnter : when you passed element | ||
* onDragEnd : when you released holding | * onDragEnd : when you released holding | ||
* set variable by useRef : //Unnecessary for re-render | |||
* set variable by useState : //Necessary for change data immediately | |||
== menuElements recursion == | == menuElements recursion == |
Revision as of 08:49, 19 June 2023
Overview
Frontend page for creating and editing MenuConfigs
Repository
visibleObj Object
let visibleObj = {
visibleRowIndex: 0, // row index we have open on page
visibleRenameRowIndex: 0, // row index currently renaming
rows:[
{
menuElements: [
{
show: false, // whether the menuElement settings are expanded
menuText
menuElements: [ // if menuElement is elementType menu, will have child menuElements
],
},
// ..
]
},
// ..
]
}
- visibleRowIndex : identify visible position row
- visibleRenameRowIndex : identify row being renamed
- show : expand or collapse elements
OnDrag
Under Construction
const dragStartRowIndex = useRef(null);
const dragPassRowIndex = useRef(null);
const [dragnamerow, setdragnamerow] = useState(null);
const [dragPassRowIndexState, setDragPassRowIndexState] = useState(null);
<div
dragable
onDragStart={(e) => {
dragStartRowIndex.current = rowIndex; //set value when clicked element
dragPassRowIndex.current = null;
setdragnamerow("row");
}}
onDragEnter={(e) => {
if (dragnamerow === "row") {
dragPassRowIndex.current = rowIndex;
setDragPassRowIndexState(rowIndex);
}
}}
onDragEnd={moveRows}
>
{"text"}
</div>
- onDragStart : when you started to click element
- onDragEnter : when you passed element
- onDragEnd : when you released holding
- set variable by useRef : //Unnecessary for re-render
- set variable by useState : //Necessary for change data immediately
- Menu elements are nested to any level
- Structure of rows and menuElements in visible object matches structure of menuConfig/menuConfigSetting