can't display the image at the first time

M MengChang Xiao 3 years 7 months ago
7 1 0

I write a simple rb file, include short javascripts.
There is a problem: when the app running,the image does not show,but display after refreshed.(in debug version)
code like this:

   
 
   
 
 
     
     
        var width = window.innerWidth;
        var height = window.innerHeight;
   
        var stage = new Konva.Stage({
          container: 'container',
          width: width,
          height: height,
          opacity:1
        });
        var backlayer = new Konva.Layer();
        stage.add(backlayer);
   
        var imageObj = new Image();
        imageObj.onload = function() {
          var image = new Konva.Image({
            x: 0,
            y: 0,
            width:width-300,
            height:height,
            image: imageObj,
          });
          backlayer.add(image);
        };
        imageObj.src = '/HEVSource/hevcar1920.jpg';
       
        onaccclick = function(){   
          hev.accelerate();
        }
        onbrakeclick = function(){   
          hev.brake();
        }
        onnaviclick = function(){  
          hev.navigate();
        }
   
        hevpos = HEVpos.createNew();
        var hev = HEVCar.createNew(stage,hevpos);
         
        var anim = new Konva.Animation(function(frame) {
          hev.work();
          backlayer.draw();
        },backlayer);
       
        anim.start();
        onaccclick();
      
 
 
 
 

the image is a little big,about 6M.
I have used the Konva. I tried html tag img too, same problem exist.
By the way,any new book on rho? I still dont know how to debug.
When debug these codes,it looks like not working,can't step in even if I have set the breakpoints.
This is JS,but the breakpoints were recognized as ruby code breakpoints.

Thanks

Please Register or Login to post a reply

1 Replies

M MengChang Xiao

Wrong page(no image):

inspector(the script is running):

after refresh(what I want):

CONTACT
Can’t find what you’re looking for?