Autodesk Forge Viewer fit to view portrait/landscape - mobile

I have a Forge viewer app where I want the camera to fit the model bounding box if the orientation on mobile devices changes.
I load the model and set the camera to a specific position in the Autodesk.Viewing.MODEL_ROOT_LOADED_EVENT event. Then I fit the model with viewer.fitToView(). That works.
In the Autodesk.Viewing.VIEWER_RESIZE_EVENT, which is also fired if the orientation of the screen changes, I run viewer.fitToView() again but the camera doesn't change.
The function doesn't seem to even run, but there is also no error message. If I zoom out of the model before changing the orientation the camera distance doesn't change although it should.
Maybe I use the wrong approach here but I can't find the problem.

Found the problem: I have locked panning of the camera:
viewer.navigation.setLockSettings({"orbit":true, "zoom":true})
viewer.navigation.setIsLocked(true)
With those settings fitToView doesn't work. I now disable locking before fitting.

Related

How to enable screen rotation with React Native?

I have been having problems with React Native screen rotation. The rotation is locked to portrait mode and I would like to enable landscape mode when the device is rotated. I use Expo to run my app on an Android device with Expo Go and haven't built the app yet. I would prefer to use only react-native APIS (e.g. Dimensions).
Edit:
The official docs say that
Multiple screen orientations should work fine by default unless you're using Dimensions API and don't handle orientation changes. If you don't want to support multiple screen orientations, you can lock the screen orientation to either portrait or landscape.
It is unclear to me what 'using Dimensions API' means and I have tried both - not using it at all (not even importing it in any of my files), and handling orientation changes with Dimensions.addEventListener.
Neither of it worked.
/Edit
I have been searching the internet for a while and I always find tutorials and guides to disable or lock screen rotation but I have the opposite problem. It seems like screen rotation is enabled by default or something.
I would appreciate any help.

Is it possible to change user's phone orientation using react?

I have the next question. I am developing a react application with some images. The user has the possibility to click and open a full-page image. Because the image's orientation is horizontal on the mobile, it does not look good. My idea is when the user clicks on the full page icon, the orientation of the phone becomes horizontal as is implemented on youtube. I tried to find some information about that, but I am not sure if it is even possible, I saw that only by using react native and developing mobile applications you can have access to the user's orientation of the screen. But maybe there are some methods to do in the browser? Thanks in advance.
It is not possible to change this from the web, however you could simply rotate the image and display it full screen. This has been done here:
CSS Rotate Portrait Image 90 Degrees and Make Image Full Screen

Codenameone Capture Photo Upside down

using the Capture class to take photos using the front facing camera (Selfie Camera) on android, the photo comes out upside down. Is there any way we can detect that the front facing camera was used so we can rotate the image if needed?
Some cameras capture the image in the orientation of the camera sensor then mark it with a special rotation flag in EXIF to indicate that the image should be viewed in a different orientation. This is common in the back camera that always captures in landscape and marks portrait images as rotated.
When you open an image using Image.createImage(filePathToImage) we implicitly detect EXIF data and adjust the image so it will be viewed correctly. Other image loading methods don't work the same way. This highly depends on the Image API you used and the Capture call you made as there are few variations of both.

Highstock not redraw immediately while dragging the navigator in mobile

I am using high stock to draw a stock chart, while moving the navigator, the chart should redraw and the setExtremes event should be triggered.
it works fine on the desktop browser, but in mobile, i found the chart is not re drawed immediately while dragging the navigator, util i let go, thus i can not get the date range while moving the navigator, that is not really good user experience.
Does anyone has a solution?
The behavior in mobile client seems the adaptToUpdatedData attribute is set to false

Responsive Adsense refresh after a screen orientation change

I've completed my responsive design, except the adsense implementation.
When for example a visitor changes the orientation of the tablet, the size of the ad should change automatically.
At the moment, I'm not getting it to work without a page refresh.
The ad only changes when I refresh the page, but that's not what a visitor would do.
According to Adsense support it has already been implemented:
Support for ad size changes after a screen orientation change. If your responsive page changes its layout following a device orientation change (e.g., when a tablet or phone goes from portrait to landscape), we’ll request and load a new ad of the correct dimensions to fit the new page layout.
However, I'm not getting it to work. Am I understanding it the wrong way, or am I missing something?
If it's not supported by Adsense yet, is there a workaround (allowed by adsense)?
EDIT: I just found out it is actually working on my smartphone. It just doesn't work with window resizing, but that's not really a problem. So I guess this is solved.
Pay close attention to the official "Technical considerations" at About responsive ad units
Your site uses third-party JavaScript
The parent container has no width set
In my case, responsive design was not setting an explicit width on viewports below 467x. As a result, the units would resize when going from portrait to landscape, but not vice versa from landscape to portrait. This resulted in a an ad unit stretching the content column wider than the viewport, and worse no ability to zoom out.
Setting an explicit width for the ad unit using a media query solved the issue, and now the units resize and cache exactly as described.

Resources