-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Describe the bug
This problem was detected during the review of #581. More details about the investigation are available in the PR.
In mxGraph, currentAlpha was null at VertexHandler instance construction, in maxGraph, its value is 100.
My guess is that the value 100 was probably chosen because the property name including the “alpha” term was mistakenly considered to carry information about opacity. This property name is used for this purpose in several places in the code, such as AbstractCanvas2D.
In #581, while trying to fix the angle of the rotation handle in the redrawHandles method:
Before the fix https://github.com/maxGraph/maxGraph/blob/v0.14.0/packages/core/src/view/handler/VertexHandler.ts#L1886
const alpha = toRadians(this.currentAlpha);mxGraph code https://github.com/jgraph/mxgraph/blob/v4.2.2/javascript/src/js/handler/mxVertexHandler.js#L2019
var alpha = mxUtils.toRadians((this.currentAlpha != null) ? this.currentAlpha : this.state.style[mxConstants.STYLE_ROTATION] || '0');Trying to use the ported mxGraph statement didn't work: the currentAlpha is always defined, so its value would have been used. As it is incorrectly computed, a wrong value would have been set to the angle.
const alpha = toRadians(this.currentAlpha ?? (this.state.style.rotation ?? 0));To Reproduce
Steps to reproduce the behavior:
- Update the code of
VertexHandlerto use currentAlpha to set the alpha - Play with a story where the rotation of vertex is enabled, for example the Stencils or Handles stories
- Rotate a vertex, stop. Then rotate it again
- Both the rotation handle and the preview shape are not at the right position
Expected behavior
We should be able to restore the mxGraph code and make the rotation work correctly in this case as well.
Screenshots
N/A
Environment
All, the problem is in the algorightm and applies all the time.
Additional context
Add any other context about the problem here.