I can select range with visual feedback
This commit is contained in:
@@ -671,12 +671,8 @@
|
||||
const element = document.getElementById(candidate.elementId);
|
||||
const dynamicValues = func(event, element, candidate.node.combinationStr);
|
||||
if (dynamicValues && typeof dynamicValues === 'object') {
|
||||
// Suffix each key with _mousedown
|
||||
const suffixed = {};
|
||||
for (const [key, value] of Object.entries(dynamicValues)) {
|
||||
suffixed[key + '_mousedown'] = value;
|
||||
}
|
||||
mousedownJsValues[candidate.elementId] = suffixed;
|
||||
// Store raw values - _mousedown suffix added at mouseup time
|
||||
mousedownJsValues[candidate.elementId] = dynamicValues;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -699,12 +695,39 @@
|
||||
// Clear pending state
|
||||
MouseRegistry.mousedownPending = null;
|
||||
|
||||
// Remove mousemove listener (no longer needed)
|
||||
// Remove mousemove listener (threshold detection no longer needed)
|
||||
if (MouseRegistry.mousemoveHandler) {
|
||||
document.removeEventListener('mousemove', MouseRegistry.mousemoveHandler);
|
||||
MouseRegistry.mousemoveHandler = null;
|
||||
}
|
||||
|
||||
// Attach on_move handler if any candidate has 'on-move' config
|
||||
const onMoveCandidates = MouseRegistry.mousedownState.candidates.filter(
|
||||
c => c.node.config && c.node.config['on-move']
|
||||
);
|
||||
if (onMoveCandidates.length > 0) {
|
||||
let rafId = null;
|
||||
MouseRegistry.mousemoveHandler = (moveEvent) => {
|
||||
if (rafId) return;
|
||||
rafId = requestAnimationFrame(() => {
|
||||
for (const candidate of onMoveCandidates) {
|
||||
const funcName = candidate.node.config['on-move'];
|
||||
try {
|
||||
const func = window[funcName];
|
||||
if (typeof func === 'function') {
|
||||
const mousedownValues = mousedownJsValues[candidate.elementId] || null;
|
||||
func(moveEvent, candidate.node.combinationStr, mousedownValues);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error calling on_move function:', e);
|
||||
}
|
||||
}
|
||||
rafId = null;
|
||||
});
|
||||
};
|
||||
document.addEventListener('mousemove', MouseRegistry.mousemoveHandler);
|
||||
}
|
||||
|
||||
// For right button: prevent context menu during drag
|
||||
if (pendingData.button === 2) {
|
||||
const preventContextMenu = (e) => {
|
||||
@@ -907,9 +930,11 @@
|
||||
Object.assign(values, config['hx-vals']);
|
||||
}
|
||||
|
||||
// 2. Merge mousedown JS values (already suffixed with _mousedown)
|
||||
// 2. Merge mousedown JS values with _mousedown suffix
|
||||
if (match.mousedownJsValues) {
|
||||
Object.assign(values, match.mousedownJsValues);
|
||||
for (const [key, value] of Object.entries(match.mousedownJsValues)) {
|
||||
values[key + '_mousedown'] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Call JS function at mouseup time, suffix with _mouseup
|
||||
|
||||
Reference in New Issue
Block a user