google chrome - Why does drawing an animated gif on canvas only update after reselecting the tab? -


I would like to display animated GIFs on the canvas with some of the changes implemented. To check things, I am currently trying to display only Animated GIF on Canvas so that it is routinely routed to GIF regularly and lt; Img & gt; is the same as displaying in the tag. P> I am using Chrome and webkitRequestAnimationFrame . On each request frame, I draw a picture. When the gif frame changes, it should be visible on the canvas. It only works partially:

  • Just viewing the canvas does not update it
  • Selecting the tab (i.e. to make another selection and selecting the canvas tab) Updates it to a new frame, but after that it freezes it again.

    This is a Bella I have installed.

    How can an animated GIIF attract me on the canvas actually animating with it ?

    the answer is no longer valid

    It looks like the behavior described here (a < Code> img tag refers to an animated GIF one canvas result, which is written in different frames of GIF, if img is a part of the DOM or is visible) less in Chrome Has changed less than. It may or may not be a document of the correct behavior for this. Besides this, webkitRequestAnimationFrame is no longer the behavior of taking an additional argument, an element X such that when X is not visible, the requested function will not run.

    Before: Before:

    H1>

    See a fixed version:

    If you add the console.log () function to the picture, you will see that it's being called. The problem is that the image itself is animate Does not, because the browser does not bother updating an animated image which is not part of the DOM.

    My solution is animated GIF Part DOM and size 0 and it works just fine.

    You can verify that the animation is being displayed on the canvas, image is loading in the tag and inspecting the elements with ctrl-shift-i

    WebkitRequestAnimationFrame

    Code> takes another argument from Mozilla's equivalent that allows your animation to run only when animated elements are visible. Check out

    Open the console and you will see that when you hide the canvas, the animation function is called. When you toggle the canvas again, the animation function will be called again.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

ruby on rails - Convert a Activerecord result with has_one associations into a single hash per record -

javascript - Read complete data from stream from onMessage -