Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8224] Mobileweb: Ti.UI.Window.open event does not mean its views are ready

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-26T14:52:29.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.0.0, Sprint 2012-07
ComponentsMobileWeb
Labelsmw-list
ReporterTony Lukasavage
AssigneeChris Barber
Created2012-03-23T10:20:32.000+0000
Updated2017-03-03T23:35:27.000+0000

Description

Problem

Executing code against views in mobileweb from the view's containing window's open event does not ensure that the view has completely loaded. I would expect for mobileweb that the Window.open event would be much like jQuery's ready, meaning that you are free to start manipulating the elements contained within it. This is not the case.

Test Case

All of the properties of view in this test case will animate from zero. I assume this is because the view's properties are not fully loaded when the window.open event fires. The comments portion with the setTimeout call will execute as expected, albeit with a 2 second delay.
var win = Ti.UI.createWindow({
	backgroundColor: '#fff',
	fullscreen: false,
	exitOnClose: true
});

var view = Ti.UI.createView({
	backgroundColor: '#a00', 
	height: 100,
	width: 100,
	top: 500,
	left: 500
});
var anim = Ti.UI.createAnimation({
	duration: 5000,
	top: 10,
	left: 10
});

win.add(view);
win.addEventListener('open', function(e) {
	// All of the view's properties will animate from zero, not the 
	// values specified above in its creation
	view.animate(anim);
	
	// This code will work 
	// setTimeout(function() {
		// view.animate(anim);
	// }, 2000);
});

win.open();

Proposed Solution

Have Window.open fire only when it and all of its child components have also loaded. This way developers can be assured that all necessary manipulations are safe in the open event.

Comments

  1. Bryan Hughes 2012-03-24

    After some discussion, the behavior for the window.open event is actually correct, however animation need to deal with this situation. In short, the bug is in animation, not window.open.
  2. Bryan Hughes 2012-03-24

    Pull Request: https://github.com/appcelerator/titanium_mobile/pull/1832
  3. Lee Morris 2017-03-03

    Closing ticket as MobileWeb is no longer supported.

JSON Source