-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Custom
The doc for options in the readme describes 3 return values for onMove corresponding to the special behaviors (false, 1 and -1): https://github.com/SortableJS/Sortable/tree/88838bfa5647e278f4cf87fdd4c3e34cd24fb33c#options
Reading the source code at
Lines 1247 to 1254 in 88838bf
| after = direction === 1; | |
| let moveVector = onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after); | |
| if (moveVector !== false) { | |
| if (moveVector === 1 || moveVector === -1) { | |
| after = (moveVector === 1); | |
| } |
onMove callback).
I opened a PR at DefinitelyTyped/DefinitelyTyped#45684 to update the type definitions to change the return type to false | 1 | -1 | void, to account for this behavior (so that the typechecker does not complain when returning nothing). but the maintainers answered saying they prefer to stick to the documented API.
Is this behavior when returning nothing an official one ? Suggested answers for preventing the move to certain positions without forcing the insertion side are relying on this, either returning nothing or returning true depending on the snippets (see #1019 and #1500 for such examples).
What should be the official signature for this callback ?
false | 1 | -1(current type definition, preventing this behavior)false | 1 | -1 | voidallowing to return nothing to keep the automatic insertion position based on the directionboolean | 1 | -1 | voidallowing to return eithertrueor nothing to keep the automatic insertion position
Based on the decision, it would be great to update the readme to reflect that in the doc (I can submit a PR once I know which variant the maintainers want)