Skip to content

Commit

Permalink
Add label API to update contentSize immediately. (cocos#3452)
Browse files Browse the repository at this point in the history
* Add label API to update contentSize immediately.

* Modify comment

* Remove updateimmediately API.
  • Loading branch information
caryliu1999 authored and pandamicro committed Nov 5, 2018
1 parent bd3942c commit cf2d4d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions cocos2d/core/components/CCLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ let Label = cc.Class({
this.node.on(cc.Node.EventType.ANCHOR_CHANGED, this._updateRenderData, this);

this._checkStringEmpty();
this._updateAssembler();
this._activateMaterial();
this._updateRenderData(true);
},

onDisable () {
Expand All @@ -486,7 +485,7 @@ let Label = cc.Class({
}
this._super();
},

_canRender () {
let result = this._super();
let font = this.font;
Expand Down
7 changes: 2 additions & 5 deletions cocos2d/core/renderer/utils/label/ttf.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = {
updateRenderData (comp) {
if (!comp._renderData.vertDirty) return;

this._updateFontFamly(comp);
this._updateFontFamily(comp);
this._updateProperties(comp);
this._calculateLabelFont();
this._calculateSplitedStrings();
Expand All @@ -141,7 +141,7 @@ module.exports = {
_updateVerts () {
},

_updateFontFamly (comp) {
_updateFontFamily (comp) {
if (!comp.useSystemFont) {
if (comp.font) {
if (comp.font._nativeAsset) {
Expand Down Expand Up @@ -418,7 +418,6 @@ module.exports = {
let paragraphedStrings = _string.split('\n');
let paragraphLength = this._calculateParagraphLength(paragraphedStrings, _context);

_splitedStrings = paragraphedStrings;
let i = 0;
let totalHeight = 0;
let maxLength = 0;
Expand Down Expand Up @@ -453,7 +452,6 @@ module.exports = {
_fontDesc = this._getFontDesc();
_context.font = _fontDesc;

_splitedStrings = [];
totalHeight = 0;
for (i = 0; i < paragraphedStrings.length; ++i) {
let j = 0;
Expand All @@ -468,7 +466,6 @@ module.exports = {
totalHeight += this._getLineHeight();
++j;
}
_splitedStrings = _splitedStrings.concat(textFragment);
}

if (tryDivideByTwo) {
Expand Down

0 comments on commit cf2d4d1

Please sign in to comment.