JavaScript loading progress of an image

前端 未结 7 1939
慢半拍i
慢半拍i 2020-11-29 18:55

Is there a way in JS to get the progress of a loading image while the image is being loaded? I want to use the new Progress tag of HTML5 to show the progress of loading imag

7条回答
  •  野性不改
    2020-11-29 19:18

    If you want to process your loaded image, than you have to add one more function, because

    thisImg.src = window.URL.createObjectURL(blob)
    

    just starts to process the image as a thread.

    You have to add a new a function to the body of load prototype, like

      this.onload = function(e)
      {
        var canvas = document.createElement('canvas')
    
        canvas.width = this.width
        canvas.height = this.height
    
        canvas.getContext('2d').drawImage(this, 0, 0)
       }
    

    This make me headache to realize :)

提交回复
热议问题