Closed DipanshKhandelwal closed 2 years ago
triggerOnChange
clear
https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L453-L468
undo
triggerOnChange is called at the end of undo :
https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L179-L184
But, simulateDrawingLines is also called on undo before triggerOnChange.
simulateDrawingLines
Now, simulateDrawingLines calls saveLine multiple times. Check line 276:
saveLine
https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L236-L279
And saveLine calls triggerOnChange at the end. Check line 446:
https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L424-L447
thanks for the in-depth analysis. Seems to be related to #93, so I'll track this issue in there.
1.
triggerOnChange
is never called onclear
https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L453-L468
2.
triggerOnChange
is called multiple times on callingundo
: [ number of lines left on undo + 1]triggerOnChange
is called at the end ofundo
:https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L179-L184
But,
simulateDrawingLines
is also called onundo
beforetriggerOnChange
.Now,
simulateDrawingLines
callssaveLine
multiple times. Check line 276:https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L236-L279
And
saveLine
callstriggerOnChange
at the end. Check line 446:https://github.com/embiem/react-canvas-draw/blob/253b68ea73c01bd2c153b8a9dcb732e4a72b8432/src/index.js#L424-L447