[TIMOB-1416] zIndex View Issue: Property changes, but is not visible until removing and re-adding the view.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:56:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.6.0 M07 |
Components | iOS |
Labels | ios, order, release-1.6.0, view, zindex |
Reporter | Fred Spencer |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:51:46.000+0000 |
Updated | 2011-04-17T01:56:07.000+0000 |
Description
The following is a quick drag and drop case. You can make this work by removing and re-adding the view, but then you have to untouch and retouch the object. That part is not in this code, but should be enough to demonstrate the issue. Please see code comments.
I have a workaround for this, but the performance is pretty terrible on device (iPad), using extra views.
var win = Ti.UI.createWindow();
var v01 = Ti.UI.createView({ name:"v01", width:100, height:100, left:0, backgroundColor:"#f00", zIndex:0 });
var v02 = Ti.UI.createView({ name:"v02", width:100, height:100, right:0, backgroundColor:"#0f0", zIndex:0 });
var vCont = Ti.UI.createView({ width:200, height:100, backgroundColor:"#00f" });
win.open(); win.add(vCont); vCont.add(v01); vCont.add(v02);
function dropView(e) {
e.source.addEventListener("touchstart", selectView);
e.source.removeEventListener("touchmove", moveView);
e.source.removeEventListener("touchend", dropView);
e.source.zIndex = 0;
}
function moveView(e) {
// un-comment the next two lines to see it working
// vCont.remove(e.source); vCont.add(e.source);
// e.source.width = 150;
// comment the next line, if un-commenting the top two
e.source.center = {x:e.x + e.source.animatedCenter.x - e.source.width / 2};
}
function selectView(e) {
e.source.zIndex = 1;
Ti.API.info("Evt Source: " + e.source.zIndex);
Ti.API.info(v01.name + " zIndex: " + v01.zIndex);
Ti.API.info(v01.name + " zIndex: " + v02.zIndex);
e.source.removeEventListener("touchstart", moveView);
e.source.addEventListener("touchmove", moveView);
e.source.addEventListener("touchend", dropView);
}
v01.addEventListener("touchstart", selectView);
v02.addEventListener("touchstart", selectView);
See issue 775:
https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/775"> https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobi...
Neat trick with the view bouncing, tho, not a particularly nice solution.
FYI, is this a dupe?
https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/1416"> https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobi...
(from [48efc48d8a2d072fbe5347247fb3748a809cc582]) [#775 status:fixed-in-qa] [#1426 status:fixed-in-qa] [#1416 status:fixed-in-qa] zIndex sorting must happen in the parent of the view whose zIndex changed. http://github.com/appcelerator/titanium_mobile/commit/48efc48d8a2d072fbe5347247fb3748a809cc582"> http://github.com/appcelerator/titanium_mobile/commit/48efc48d8a2d0...
(from [6a5a8a1cd4fe1e05fbfcfb076d3a1bdb9238d27b]) [#775 status:fixed-in-qa] [#1426 status:fixed-in-qa] [#1416 status:fixed-in-qa] zIndex sorting must happen in the parent of the view whose zIndex changed. http://github.com/appcelerator/titanium_mobile/commit/6a5a8a1cd4fe1e05fbfcfb076d3a1bdb9238d27b"> http://github.com/appcelerator/titanium_mobile/commit/6a5a8a1cd4fe1...
(from [483124c7082e31db4e80b3de4739f7eeb703da27]) [#2183 state:fixed-in-qa] [#775 state:fixed-in-qa] [#2092 state:fixed-in-qa] [#1426 state:fixed-in-qa] [#1416 state:fixed-in-qa] This time, zIndex is fixed for sure! Really now! Honest! http://github.com/appcelerator/titanium_mobile/commit/483124c7082e31db4e80b3de4739f7eeb703da27"> http://github.com/appcelerator/titanium_mobile/commit/483124c7082e3...
Mea culpa. This is because setZIndex is expecting an int, but we pass an object. The workaround is to do view.animate({zIndex:}); which does a different code path.
The fix will be in KrollObject.m, lines 793:
Replace with [target setValue:value forKey:key];, since it will check for setFoo anyways, and faster. Since we're so close to 1.5.0, pushing to 1.5.1.
(from [97ef54ba316f4b52d6e9aecb50977d4561d87c89]) [#1416 state:fixed-in-qa] checking for setFoo was redundant and didn't account for non-object arguments https://github.com/appcelerator/titanium_mobile/commit/97ef54ba316f4b52d6e9aecb50977d4561d87c89"> https://github.com/appcelerator/titanium_mobile/commit/97ef54ba316f...
(from [e8a8ee647699f2ab443583a300b0da3eabb5d863]) Revert "[#1416 state:fixed-in-qa] checking for setFoo was redundant and didn't account for non-object arguments"
This reverts commit 97ef54ba316f4b52d6e9aecb50977d4561d87c89.
https://github.com/appcelerator/titanium_mobile/commit/e8a8ee647699f2ab443583a300b0da3eabb5d863"> https://github.com/appcelerator/titanium_mobile/commit/e8a8ee647699...
(from [c4cca8b8dc8b30af5883ecce20e328fd830b1f2e]) Revert "Revert "[#1416 state:fixed-in-qa] checking for setFoo was redundant and didn't account for non-object arguments""
This reverts commit e8a8ee647699f2ab443583a300b0da3eabb5d863.
https://github.com/appcelerator/titanium_mobile/commit/c4cca8b8dc8b30af5883ecce20e328fd830b1f2e"> https://github.com/appcelerator/titanium_mobile/commit/c4cca8b8dc8b...
Fix moved from master. It's still open again.
(from [a418c7495fa816675b62f2b2580da0e61ce3840b]) [#1416 state:fixed-in-qa] Ensuring that zIndex is setValue:forKey:ed. https://github.com/appcelerator/titanium_mobile/commit/a418c7495fa816675b62f2b2580da0e61ce3840b"> https://github.com/appcelerator/titanium_mobile/commit/a418c7495fa8...
Test is put into Integrity. Unclear on the behavior expected and how to validate fix.
Tested simulator 4.2.1 release, iPod 3GT 4.2.1 release. Behavior is as expected.