-
15 Dec 2011 6:16 PM #1
Unanswered: Why is onOrientationChange being triggered twice?
Unanswered: Why is onOrientationChange being triggered twice?
When I change the orientation, its triggering the call to onOrientationChange twice for each time it changes. Is it supposed to do that? I will be putting some code in there to alter the layout, and I dont want to have it called twice.
Code:app.views.Viewport = Ext.extend(Ext.TabPanel, { fullscreen: true, id: 'viewport', layout: 'card', monitorOrientation: true, tabBar: { dock: 'bottom', ui: 'light', layout: {pack: 'center'} }, cardSwitchAnimation: 'slide', initComponent: function() { // ... app.views.Viewport.superclass.initComponent.apply(this, arguments); }, onOrientationChange: function(orientation, w, h) { console.log(orientation); console.log(w); console.log(h); } }); Ext.regApplication({ name: 'app', setup: { phoneStartupScreen: "img/test.jpg" }, launch: function() { this.launched = true; this.mainLaunch(); }, mainLaunch: function() { if(!device || !this.launched) { return; } this.views.viewport = new this.views.Viewport(); } });
-
16 Dec 2011 7:07 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
It will fire when the browser's resize event is thrown. Is the orientationchange event fired twice? It would be simple to buffer them to only fire once:
50 is the number of milliseconds to buffer the event firings together. Basically only the last one in that 50ms will fire.Code:this.on('orientationchange', someFn, this, { buffer : 50 });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote