PDA

View Full Version : delay between orientationchange dispatch and capture



csimon
19 Oct 2010, 8:39 AM
Hi,

I'm looking for dispatching orientationchange and beforeorientationchange right in the time.
But if you try the simple code below:

log = function(name){
console.log(Ext.util.Format.format('"{0}": {1} msec', name, (new Date()).getMilliseconds()));
}

Ext.setup({
onReady: function() {
var panel = new Ext.Panel({
fullscreen: true,
orientationMonitor:true,
listeners:{
beforeorientationchange:function(){ log("beforeorientationchange"); },
orientationchange:function(){ log("orientationchange"); }
}
});
var e = document.createEvent('Events');
e.initEvent('orientationchange', true, false);
e.orientation = "landscape";
document.dispatchEvent(e);
log("dispatch");
}
});

you get a log like this:

"dispatch": 240 msec
"beforeorientationchange": 671 msec
"orientationchange": 672 msec

where the orientation change events are fired pretty much in the same time and both,
about 0.5 seconds after dispatching orientationchange.

Is possible to set that delay without breaking the sencha event machinery?

It seems that sencha defines beforeorientationchange subject to orientationchange ...
it is possible to separate them?

Thanks and regards,

Simone

jay@moduscreate.com
19 Oct 2010, 9:24 AM
each "listener" can be configured with a delay attribute.

csimon
20 Oct 2010, 2:48 AM
Thanks for your reply.
I tried also with:
panel.addListener(eventName, handler, scope, {delay:0});
but the result is the same, between the document.dispatchEvent and the handler calls there is always the half second delay (actually a little less ... about 433 ms).
I would like to eliminate that delay because the beforeorientationchange handler would be probably called at the right time, that is before turning the browser view and not after, as it happens.
I thought it was a delay too large to be attributed to the run-time code between dispatch and capture of the event ...