- Welcome, Guest. Please Login or Register
MindFusion  
  Version 2 of our Xamarin Calendar component adds Resource view and support for Universal Windows Platform. Now beta testing spreadsheet component for Java Swing.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Diagram with custom Node - Image not shown first load
Read 146 times

Ghaith   Offline
YaBB Newbies
*
Posts: 3
I Love MindFusion!


   
     
 
Diagram with custom Node - Image not shown first load
Apr 7th, 2017 at 1:41pm
 
I have created a custom node containing couple of text and images, and was working fine, but the nodes started to load with the text only, and the images is not there, until I click on the node, then the images appeared. I don't know If it is because something I did or some property I changed.

I checked the console in Chrome, the function "updateCanvasElements" already called and the images are pushed.
I tested on IE, everything is okay as usual.

I searched, but nothing I could found or someone having the same problem.

Any Ideas? Hin?
 
 
« Last Edit: Apr 7th, 2017 at 3:04pm by Ghaith »
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 881
Gender: male
tech.support


   
     
 
Re: Diagram with custom Node - Image not shown first load
Reply #1 - Apr 7th, 2017 at 4:47pm
 
The DOM image might have not downloaded yet the first time you try to draw it. You could check the image.complete property, and if it's false call diagram.repaint() to schedule a redraw. You could as well subscribe to the image.load event. That's similar to what was discussed in this thread - http://mindfusion.eu/Forum/YaBB.pl?num=1488530760/15#15
 
 
 
IP Logged    
 
     

Ghaith   Offline
YaBB Newbies
*
Posts: 3
I Love MindFusion!


   
     
 
Re: Diagram with custom Node - Image not shown first load
Reply #2 - Apr 7th, 2017 at 7:32pm
 
Dear this is the code I am using
//Add image
var imgFile = new Image();
imgFile.src = 'data:image/png;base64,' + f.value;
imgFile.addEventListener("load", function () {
                });

var img = new MindFusion.Drawing.Image(
new MindFusion.Drawing.Rect(this.bounds.x + p.position_X, this.bounds.y + p.position_Y, p.width, p.height));
img.image = imgFile;
img.loaded = imgFile.complete;

this.graphicsContainer.content.push(img);

but this didn't help
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 881
Gender: male
tech.support


   
     
 
Re: Diagram with custom Node - Image not shown first load
Reply #3 - Apr 8th, 2017 at 12:43pm
 
Try this handler -

Code:
imgFile.addEventListener("load", function () {
	img.loaded = true;
	node.invalidate();
}); 



Regards,
Slavcho
Mindfusion
 
 
 
IP Logged    
 
     

Ghaith   Offline
YaBB Newbies
*
Posts: 3
I Love MindFusion!


   
     
 
Re: Diagram with custom Node - Image not shown first load
Reply #4 - Apr 10th, 2017 at 2:44pm
 
That solved the problem.

Many thanks
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print