Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Using Corona as a native wrapper for Web-based business apps
Started by horacebury Jan 22 2014 12:46 PM

2 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,070 posts
  • Corona SDK

I'd like to know if anyone has done this and how they handled rotation of the webview?



[TOPIC: post.html]
#2

CineTek

[GLOBAL: userInfoPane.html]
CineTek
  • Contributor

  • 310 posts
  • Corona SDK

The simplest method is to change the rotation property. With Graphics 2.0 you could add a fancy effect as a transition. I haven´t done this by myself yet but I will include something like this in the near future



[TOPIC: post.html]
#3

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 3,070 posts
  • Corona SDK

I've been testing with the code below, but the on-device result is that the web view simply distorts. The problem with the rotation is that the width and height of the device are different, so I was hoping to change the width and height of the web view. If I don't rotate the web view I have to account for device rotation in HTML/JS.

 

-- web app test

display.setDefault( "background", 1, 0, 0 )

local pWidth, pHeight = display.actualContentWidth, display.actualContentHeight

local webView = native.newWebView( pWidth/2, pHeight/2, pWidth-100, pHeight-100 )
webView:request( "http://www.coronalabs.com/" )

local orientations = {}
orientations.portrait = { rotation=0, width=pWidth, height=pHeight, x=pWidth/2, y=pHeight/2 }
orientations.portraitUpsideDown = { rotation=180, width=pWidth, height=pHeight, x=pWidth/2, y=pHeight/2 }
orientations.landscapeLeft = { rotation=-90, width=pHeight, height=pWidth, x=pHeight/2, y=pWidth/2 }
orientations.landscapeRight = { rotation=90, width=pHeight, height=pWidth, x=pHeight/2, y=pWidth/2 }

local function onOrientationChange( event )
	local currentOrientation = event.type
	print( "Current orientation: " .. currentOrientation )
	
	local o = orientations[ currentOrientation ]
	
	transition.to( webView, { x=o.x, y=o.y, rotation=o.rotation, width=o.width, height=o.height, time=0 } )
	print(o.x, o.y, o.rotation, o.width, o.height)
end

Runtime:addEventListener( "orientation", onOrientationChange )




[topic_controls]
[/topic_controls]