zetay / blockly

Automatically exported from code.google.com/p/blockly
1 stars 1 forks source link

How to 'refresh' workspace or all blocks? #242

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!

I'm trying to change workspace's blocks size in real time:

var blocks = window.Blockly.mainWorkspace.getAllBlocks();

$.each(blocks,function(i,block) {
    block.svg_.width = block.svg_.width * 1.5;
    block.svg_.height = block.svg_.height * 1.5;
});

Now It seems that I have to "refresh" or "redraw" the workspace or all the 
blocks in order to render them with their new dimensions, but I'm not able to 
find in the documentation how to do it. Any help would be great!

Thanks in advance!

Oscar

Original issue reported on code.google.com by oferran...@gmail.com on 23 Jul 2014 at 11:17

GoogleCodeExporter commented 9 years ago
Hello! I'm in a somewhat similar situation, where I use CSS to control whether 
the Blockly interface should be displayed or not. I'm not sure if this is the 
right way to do things, but after reading a bit of core/inject.js (in the 
Blockly source code repo), I've found that simulating a resize event on the 
Blockly window with the following code does the trick for me:

Blockly.fireUiEvent(window, 'resize');

Hope this helps.

Original comment by var...@gmail.com on 6 Nov 2014 at 11:24