-
23 Jul 2010 3:12 AM #1
Sencha + Phonegap orientation problem
Sencha + Phonegap orientation problem
Hi,
For sencha team thank you for this beautiful tools ! Sencha is the best way for webapp !
So my problem. My web app work perfectily and whan i change the orientation, no problem.
But when i embed my webapp via phone gap the orientation change keep the initial position.
I found this solution then i use with a onOrientationChange of panel :
http://stackoverflow.com/questions/2...scape-portrait
but doesn't work ! any pist or way where i can find a solution ?
Thx
Fabien
-
23 Jul 2010 7:02 AM #2
I am having the same problem. I am using the Kitchen Sink demo and PhoneGap. The orientation adjustment happens in the browser fine but when you run it on an iPad or the simulator with PhoneGap, the onOrientationChange function/listener does not seem to work, except on first load. Please help!
-
26 Jul 2010 7:01 AM #3
so the phonegap don't send the onorientationchange event and use the orientationchanged event init by the phonegap.js.
But phonegap.js gave error with sencha.
i found this solution : http://groups.google.com/group/phone...438ccb9111c2ca
if i have more information i post the solution here.
see you.
Fabien
-
30 Jul 2010 7:27 AM #4
Hey Fabien,
I have been following your threads since yesterday. I am also trying to launch an iPad app into the app store and my final step is getting the orientation to change on the ipad with Sencha and PhoneGap.
So far, this is the only thing that has worked for me:
I added that line to the index.html file and I created a function in my sencha file for the callback.Code:<script> document.addEventListener("orientationChanged", yourCallbackFunction, false); </script>
Sencha app.js
So, basically now I am trying to get Sencha to "refresh" or stretch out on the screen like when it first starts. I have tried doLayout(), but that did not work.Code:function yourCallbackFunction() { //alert("PhoneGap has triggered the event!"); // Now I need to have Sencha refresh the Panel? }
If you have some luck with this let me know.
-
30 Jul 2010 1:27 PM #5
Fabien,
I finally got this to work. I had the same problem you were having with PhoneGap and Sencha. Apparently Sencha, does recognize the WindowResize event so I used that event to manually resize my main Panel.
Keep in mind that in the above code, my main panel is the variable name "mainPanel". This worked like a charm.Code:new Ext.setup({ glossOnIcon: false, onReady: function() { // Regular EXT JS application code here // ...... // Setup a callback for WindowResize Event Ext.EventManager.onWindowResize( senchaChangeOrientation ); } }); // Callback function senchaChangeOrientation() { if(Ext.getOrientation()=="landscape") { mainPanel.setSize(1024,748); mainPanel.doLayout(); }else { mainPanel.setSize(768,1004); mainPanel.doLayout(); } }
-
3 Aug 2010 12:19 AM #6
Many thanks for your answers ! i test these solution and it work fine !
-
10 Aug 2010 11:14 PM #7
hi, i'm a newbie sencha user so probably my question is very "dummy"...
i have a similar problem using sencha-phonegap.
my application should display 2 different view:- in portrait, i want a long test with scrolling enabled
- in landscape, i need to display an image that fits the screen bounds with no scrolling at all
I created an html with 2 'divs' containing the 2 views: they are included in a container 'div' called my-div and are made visible/invisible using css media queries.
then i created a fullscreen panel with the content of my-div and tried to catch window resize event in order to set the panel size as in the example above. but it didn't worked...
When i'm in portrait and scroll to bottom and then i rotate to landscape, the scrolling is still active and the image is not visible because is on the top and i have to scroll to view it...
do you have any suggestion to fix this problem or a different solution?Code:new Ext.setup({ onReady: function(){ mainPanel = new Ext.Panel { contentEl: 'my-div', scroll: 'vertical', fullscreen: true // Setup a callback for WindowResize Event Ext.EventManager.onWindowResize( senchaChangeOrientation ); } }); // Callback function senchaChangeOrientation() { if(Ext.getOrientation()=="landscape") { mainPanel.setSize(480,320); mainPanel.setScrollable('false'); mainPanel.doLayout(); } else { mainPanel.setSize(320,480); mainPanel.setScrollable('vertical'); mainPanel.doLayout(); } };
thanks in advance for any help.
Luca
-
11 Aug 2010 5:48 AM #8
Although this is not the fix you are looking for, I have suggested some syntax correction from the code you provided. I believe the callback was not working before, because of where you had that line of code.
Code:new Ext.setup({ onReady: function(){ mainPanel = new Ext.Panel({ contentEl: 'my-div', scroll: 'vertical', fullscreen: true }); // Setup a callback for WindowResize Event Ext.EventManager.onWindowResize( senchaChangeOrientation ); }); // Callback function senchaChangeOrientation() { if(Ext.getOrientation()=="landscape") { mainPanel.setSize(480,320); mainPanel.setScrollable('false'); mainPanel.doLayout(); } else { mainPanel.setSize(320,480); mainPanel.setScrollable('vertical'); mainPanel.doLayout(); } };
-
11 Aug 2010 8:27 AM #9
yes. it was a typing error...there is also a missing curly bracket after the line:
Ext.EventManager.onWindowResize( senchaChangeOrientation );
by the way, the event is catched by senchaChangeOrientation function (i tried to display an alert and worked...) but after few seconds the application crashes...
-
11 Aug 2010 9:11 AM #10
finally i got it to work!
it was simpler than i believed...simply declared 2 panel with a card layout and set active item on window resize
here's the code i used.
Code:Ext.setup({ onReady: function() { panel = new Ext.Panel({ fullscreen: true, layout: 'card', items:[{xtype:'panel',contentEl:'portrait-container',scroll:'vertical'}, {xtype:'panel',contentEl:'landscape-container',scroll:'false'}] }); Ext.EventManager.onWindowResize(setActivePanel); } }); function setActivePanel(){ if (Ext.getOrientation()=="landscape") { panel.getLayout().setActiveItem(1); } else { panel.getLayout().setActiveItem(0); } };
Similar Threads
-
Conflict wit sencha / phonegap & html5 database
By erneso.laval in forum Sencha Touch 1.x: DiscussionReplies: 4Last Post: 11 Jul 2011, 7:13 PM -
Preventing orientation changes?
By SuperTron in forum Sencha Touch 1.x: DiscussionReplies: 2Last Post: 19 Jul 2010, 11:20 AM -
sencha touch list store problem
By reminder in forum Sencha Touch 1.x: DiscussionReplies: 1Last Post: 27 Jun 2010, 11:33 AM -
Tab Orientation
By garyrgi in forum Ext 1.x: Help & DiscussionReplies: 2Last Post: 7 Nov 2006, 9:49 AM


Reply With Quote