Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2822] View "size" property shouldn't be used for dimension values manipulation

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2012-02-23T12:11:27.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvan Skugor
AssigneeMauro Parra-Miranda
Created2012-02-14T05:21:49.000+0000
Updated2016-03-08T07:47:45.000+0000

Description

The problem

In this KitchenSink example: https://github.com/appcelerator/KitchenSink/blob/master/Resources/examples/view_with_size.js "size" property is used to define and manipulate view dimension values:
var view = Ti.UI.createView({
	size:{
		width:100,
		height:100
	},
	backgroundColor:"red"
});

button.addEventListener('click',function() {
    view.size = {width:150,height:150};
    label.text = "Box should now be 150x150";
});

Expected behavior

Since "size" object's properties "width" and "height" reflect rendered view's dimension values, behavior from KitchenSink example is unintuitive and confusing. In my opinion that behavior should be removed (from KitchenSink and from SDK). Only valid use case should be this:
var view = Ti.UI.createView({ height: '50%', width: 'auto' });

...

view.height // 50%
view.width // 'auto'
view.size.height // 200 (for example), readonly
view.size.width // 42 (for example), readonly

Comments

  1. Ivan Skugor 2012-02-14

    From documentation: "The size property is a read-only dictionary with two properties, width and height." https://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.View-object
  2. Mauro Parra-Miranda 2012-02-23

    As commented, already documented. Not a bug.
  3. Ivan Skugor 2012-02-24

    I don't understand. This should be a bug, I commented that "size" property is read-only (from documentation), while in KitchenSink example there is a code that writes to that property: "view.size = {width:150,height:150};"
  4. Mauro Parra-Miranda 2013-11-24

    Invalid issue.

JSON Source