CreateJS / EaselJS

The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
http://createjs.com/
MIT License
8.11k stars 1.97k forks source link

DisplayObject.getBounds() reports wrong value after object is cached #1014

Open djipco opened 5 years ago

djipco commented 5 years ago

The documentation for DisplayObject.getBounds() states: "Likewise, display objects that have been cached using cache() will return the bounds of their cache". However, when I run the code below, this is not what I'm getting:

let text = new createjs.Text("Hello, world!", "20px Arial", "#ff7700");
console.log(text.getBounds());
text.cache(0, 0, text.getBounds().width, text.getBounds().height);
console.log(text.getBounds());

Console output:

Rectangle {x: 0, y: 0, width: 110.0390625, height: 19.9921875}
Rectangle {x: 0, y: 0, width: 0, height: 0}

The behaviour is the same with Stage and StageGL (CreateJS v1.0.0). Am I missing something obvious or is this wrong?

djipco commented 5 years ago

I just tried this code with easeljs.NEXT.js and it seems to have been fixed. Excellent! Is there an ETA for the next release?

djipco commented 5 years ago

I create a PR (#1016) to clarify that this started to work with v1.0.2. I think this is necessary because most users are still using the version on the CDN (1.0.0).