Add keep css class option #854
Conversation
- Resetting them when dropping element
lukasoppermann
left a comment
There was a problem hiding this comment.
Please remove all files in the dist folder from the pr. This is always done on release only.
| } | ||
| // We need to reset placeholder if any css class were added. | ||
| options.keepCssClass.forEach(className => { | ||
| store(sortableElement).placeholder.classList.remove(className) |
There was a problem hiding this comment.
This can be done in one step https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/remove sot that all classes are provided at once.
I think this should work: remove(...options.keepCssClass)
| store(sortableElement).placeholder.style.height = draggingHeight + 'px' | ||
| store(sortableElement).placeholder.style.width = draggingWidth + 'px' | ||
| } | ||
| // Keep some CSS class fo the dragged element, to keep style. |
| } | ||
| // Keep some CSS class fo the dragged element, to keep style. | ||
| // Usefull if sortable elements have different dimensions according class. | ||
| options.keepCssClass.forEach(className => { |
There was a problem hiding this comment.
I think from a performance point of view you should first get the elements you want to add. Maybe use filter to get the elements that are in both arrays.
Afterwards just like with remove, you can add all at once. DOM interactions are often expensive.
add(...comparedArray)
There was a problem hiding this comment.
Sorry you lost me in the first sentence.
Second sentence nice did't know that too.
| handle?: string, | ||
| forcePlaceholderSize?:boolean; | ||
| forcePlaceholderSize?: boolean, | ||
| keepCssClass?: Array<string>, |
There was a problem hiding this comment.
Let's rename this to keepClassesForPlaceholder.
|
Hey @heyyo-droid thank you for the PR. I left a few comments. I am thinking if it may make more sense to have an initialize placeholder function that the user can define. We would add a What do you think? |
Allow to keep some css class from dragged element and apply them to placehoder.