Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust fix for the "this.canvas" undefined situation #2138

Closed
wants to merge 1 commit into from
Closed

More robust fix for the "this.canvas" undefined situation #2138

wants to merge 1 commit into from

Conversation

asturur
Copy link
Member

@asturur asturur commented Apr 21, 2015

Bug introduced with #2083 and partially fixed with #2120.

to be discussed, do not merge.

@sapics
Copy link
Contributor

sapics commented Apr 22, 2015

@asturur Thank you for quick fix!

Sorry, I know little about transform.

If the purpose is to avoid undefined, getCanvas function would be better to

return (this.group && this.group.getCanvas()) || this.canvas

I am afraid that, if we need to know ctx is come from which canvas, we need more complex function like below (sorry, i do not know which canvas element would be transformed, this is just a example).

getCanvas(ctx.canvas);
...
getCanvas: function(canvasEl) {
  if (canvasEl && this.canvas) {
    if((this.canvas.upperCanvasEl && this.canvas.upperCanvasEl === canvasEl)
       || (this.canvas.lowerCanvasEl && this.canvas.lowerCanvasEl === canvasEl)
       || (this.canvas.cacheCanvasEl && this.canvas.cacheCanvasEl === canvasEl)) {
      return this.canvas
    }
  }
  return this.group && this.group.getCanvas(canvasEl)
  // or return (this.group && this.group.getCanvas(canvasEl)) || this.canvas
},

@asturur
Copy link
Member Author

asturur commented Apr 22, 2015

i do not need to know the canvas element.
I need just the canvas object to know the preserveObjectStacking parameter
I ended up doing another thing, simpler, that is ensure that every object on canvas HAS is .canvas property set.

@asturur asturur closed this Apr 22, 2015
@asturur asturur deleted the fix-render-preserve branch April 22, 2015 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants