Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed resizing of relative widgets #338

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
### **WORK IN PROGRESS**
-->
## Changelog
### **WORK IN PROGRESS**
* (foxriver76) fixed resizing issue for relative widgets

### 2.9.24 (2024-01-24)
* (foxriver76) Image 8 widget ported to react

Expand Down
58 changes: 28 additions & 30 deletions src/src/Vis/visView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,41 +428,39 @@ class VisView extends React.Component {
return;
}

if (!isRelative) {
this.refView.current.addEventListener('mousemove', this.onMouseWidgetMove);
window.document.addEventListener('mouseup', this.onMouseWidgetUp);
this.refView.current.addEventListener('mousemove', this.onMouseWidgetMove);
window.document.addEventListener('mouseup', this.onMouseWidgetUp);

this.movement = {
moved: false,
startX: e.pageX,
startY: e.pageY,
isResize,
x: 0,
y: 0,
};
this.movement = {
moved: false,
startX: e.pageX,
startY: e.pageY,
isResize,
x: 0,
y: 0,
};

const widgetsRefs = this.widgetsRefs;
const widgetsRefs = this.widgetsRefs;

this.props.selectedWidgets.forEach(selectedWidget => {
const widgetRect = widgetsRefs[selectedWidget].refService.current.getBoundingClientRect();
if (e.pageX <= widgetRect.right && e.pageX >= widgetRect.left && e.pageY <= widgetRect.bottom && e.pageY >= widgetRect.top) {
this.movement.startWidget = widgetsRefs[selectedWidget].refService.current.getBoundingClientRect();
}
});
this.props.selectedWidgets.forEach(selectedWidget => {
const widgetRect = widgetsRefs[selectedWidget].refService.current.getBoundingClientRect();
if (e.pageX <= widgetRect.right && e.pageX >= widgetRect.left && e.pageY <= widgetRect.bottom && e.pageY >= widgetRect.top) {
this.movement.startWidget = widgetsRefs[selectedWidget].refService.current.getBoundingClientRect();
}
});

this.props.selectedWidgets.forEach(_wid => {
if (widgetsRefs[_wid]?.onMove) {
widgetsRefs[_wid].onMove(); // indicate the start of movement
}
});
this.props.selectedWidgets.forEach(_wid => {
if (widgetsRefs[_wid]?.onMove) {
widgetsRefs[_wid].onMove(); // indicate the start of movement
}
});

// Indicate about movement start
Object.keys(widgetsRefs).forEach(_wid => {
if (widgetsRefs[_wid]?.onCommand) {
widgetsRefs[_wid].onCommand('startMove');
}
});
}
// Indicate about movement start
Object.keys(widgetsRefs).forEach(_wid => {
if (widgetsRefs[_wid]?.onCommand) {
widgetsRefs[_wid].onCommand('startMove');
}
});
};

onIgnoreMouseEvents = ignore => {
Expand Down
Loading