Skip to content
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
9 changes: 8 additions & 1 deletion packages/blockly/core/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ let content = `

.blocklyBlockCanvas.blocklyCanvasTransitioning,
.blocklyBubbleCanvas.blocklyCanvasTransitioning {
transition: transform .5s;
transition: transform .15s;
}

@media (prefers-reduced-motion) {
.blocklyBlockCanvas.blocklyCanvasTransitioning,
.blocklyBubbleCanvas.blocklyCanvasTransitioning {
transition: none;
}
}

.blocklyEmboss {
Expand Down
14 changes: 8 additions & 6 deletions packages/blockly/core/layer_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ export class LayerManager {
* @internal
*/
appendToAnimationLayer(elem: IRenderedElement) {
const currentTransform = this.dragLayer?.getAttribute('transform');
const currentTransform = this.dragLayer?.style.transform;
// Only update the current transform when appending, so animations don't
// move if the workspace moves.
if (currentTransform) {
this.animationLayer?.setAttribute('transform', currentTransform);
if (currentTransform && this.animationLayer) {
this.animationLayer.style.transform = currentTransform;
}
this.animationLayer?.appendChild(elem.getSvgRoot());
}
Expand All @@ -88,10 +88,12 @@ export class LayerManager {
* @internal
*/
translateLayers(newCoord: Coordinate, newScale: number) {
const translation = `translate(${newCoord.x}, ${newCoord.y}) scale(${newScale})`;
this.dragLayer?.setAttribute('transform', translation);
const translation = `translate(${newCoord.x}px, ${newCoord.y}px) scale(${newScale})`;
if (this.dragLayer) {
this.dragLayer.style.transform = translation;
}
for (const [_, layer] of this.layers) {
layer.setAttribute('transform', translation);
layer.style.transform = translation;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/blockly/core/zoom_controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,10 @@ export class ZoomControls implements IPositionable {
* @param e A mouse down event.
*/
private zoom(amount: number, e: PointerEvent) {
this.workspace.beginCanvasTransition();
this.workspace.markFocused();
this.workspace.zoomCenter(amount);
setTimeout(this.workspace.endCanvasTransition.bind(this.workspace), 150);
this.fireZoomEvent();
Touch.clearTouchIdentifier(); // Don't block future drags.
e.stopPropagation(); // Don't start a workspace scroll.
Expand Down Expand Up @@ -459,7 +461,7 @@ export class ZoomControls implements IPositionable {
this.workspace.zoomCenter(amount);
this.workspace.scrollCenter();

setTimeout(this.workspace.endCanvasTransition.bind(this.workspace), 500);
setTimeout(this.workspace.endCanvasTransition.bind(this.workspace), 150);
this.fireZoomEvent();
Touch.clearTouchIdentifier(); // Don't block future drags.
e.stopPropagation(); // Don't start a workspace scroll.
Expand Down