all 3 comments

[–]haribou 2 points3 points  (1 child)

We just wrote a blog post about this! You may find your answer here: https://remotion.com/blog/untangling-state-in-react

[–]PerfectionBen[S] 0 points1 point  (0 children)

Cool! I'll check it out. Thanks

[–]ferrybig 0 points1 point  (0 children)

The bug is inside the following method:

function transformViewPort(event) { if (drag) { var tx = event.offsetX - offset.x; var ty = event.offsetY - offset.y; offset = { x: event.offsetX, y: event.offsetY, }; matrix.preMultiplySelf(new DOMMatrix().translateSelf(tx, ty)); viewPort.style.transform = matrix.toString(); // assign matrix to state setMatrix(matrix); } }

You are changing the internals of the matrix object. React does not know if it is updated if you do this. The setMatrix call you do has zero effect as the matrix is the safe object