Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9326] iOS: View - will not animate if height is 0 (zero)

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionDuplicate
Resolution Date2021-05-21T21:28:50.000+0000
Affected Version/sRelease 2.1.0, Release 2.0.1, Release 3.1.0
Fix Version/sn/a
ComponentsiOS
Labelscore, easy-fix, reprod
ReporterJon Alter
AssigneeUnknown
Created2012-05-30T21:49:15.000+0000
Updated2021-05-21T21:28:50.000+0000

Description

If the height of a view is set to zero it will not animate, even to a larger height.

Steps to reproduce:

Step 1: run the code below Step 2: click on the "shrink" button Step 3: notice the blue view shrink Step 4: click the "expand" button Step 5: notice the blue view does not expand Step 6: if you replace the 0 height with another number greater than zero, the animation will work as expected
var win2  = Ti.UI.createWindow({
	backgroundColor: 'green'
});
win2.open();

var view = Ti.UI.createView({
	backgroundColor: 'blue',
	top: 200,
	height: 200,
	width: 200
});
win2.add(view);

var b1 = Ti.UI.createButton({
	title: 'shrink',
	top: 5,
	left: 5
});
b1.addEventListener("click", function(){
	view.animate({
		height: 0,
		duration: 500
	}, function(){
		Ti.API.info('shrink complete');
	});
});
win2.add(b1);

var b2 = Ti.UI.createButton({
	title: 'expand',
	top: 5,
	left: 200
});
b2.addEventListener("click", function(){
	// workaround
	// view.height = 1;
	view.animate({
		height: 200,
		duration: 500
	}, function(){
		Ti.API.info('expand complete');
	});
});
win2.add(b2);

Workaround:

Set the height of the view to a number greater than 0 before animating (see the example).

Comments

  1. Lutz Bayer 2012-07-13

    I can confirm this Bug. It also appears if you want so start an animation on an view and view-height of value zero. @API: SDK 2.1.0.GA @iOS: 5.1 @OS: Mac Lion (10.7.4)
  2. jithinpv 2013-04-01

    Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
  3. Shawn Berg 2013-05-01

    I'm running into the same exact issue. Any ETA on a resolution? Application Type: mobile Titanium SDK: 3.1.0GA Platform: iOS 6.1 Device: iOS Simulator Host OS: Max OSX 10.8.3 Titanium Studio: 3.1.1.201304291957
  4. levani 2014-01-25

    This issue is still unresolved on Ti 3.2.0GA. At least on ios 7.
  5. Lee Morris 2017-06-23

    I am able to reproduce this issue with the following environment; iPhone 7 (10.2) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170620103414 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131
  6. Guile 2018-02-22

    This bug still appears...

JSON Source