Questions tagged [device-orientation]
Use device-orientation for questions related to coding for both landscape and portrait modes of a device which can be rotated by the user
501
questions
-1
votes
0
answers
29
views
SwiftUI - how to allow landscape in one view, but prevent in other?
Using SwiftUI, I want the ability to allow a single view to transition to landscape/portrait based on how the user is holding it - however, for a second view, I want to force/lock the user to view it ...
0
votes
1
answer
42
views
Fix Orientation and list for changes - SWIFT
I'm new to iOS development and struggling with orientation checks. I have fixed the orientation for my view and now want to see the orientation it's held in.
How I've fixed it:
APP DELEGATE
...
0
votes
1
answer
46
views
Typescript React how to store an Object permanently
Good day,
I am coding a compass application in react and have some problems.
I am working with a DeviceOrientationEvent, if i add an EventListener it orientates to the device heading, not to the ...
0
votes
0
answers
32
views
iPhone app on iPad running iOS15 does not run in enlarged mode in landscape orientation
I have an iPhone only targeted app with device orientation support for Portrait, Landscape Left and Landscape Right, as shown below
The app runs as expected on an iPhone across different iOS versions ...
1
vote
1
answer
58
views
How to allow landscape for tablets, but prevent it on mobile phones?
I'm forcing portrait mode on mobile phones,
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome....
1
vote
1
answer
231
views
Rotate map based on device orientation in Openlayer
I am writing an application using osm in Openlayers. I'm having trouble adjusting the direction. I determine the direction of the device. Keeping the icon fixed and rotating the map shows the ...
0
votes
0
answers
29
views
Flutter recognise device orientation changed even when Potrait mode is forced
in my app I have a page to take photos. When rotating the device, the page should be locked in potrait mode and only the icons in the appbar should rotate. (The behavior is identical to the iOS camera)...
0
votes
0
answers
38
views
All deviceorientation events return NULL on Samsung Phone
According to caniuse I should be able to read deviceorientation (tilt data of the device) via a Samsung Browser but can't.
I have tried viewing https://sensorbox.glitch.me/ on a Samsung device and all ...
21
votes
1
answer
643
views
The simplest way to solve gimbal lock when using DeviceOrientation events in javascript - How to make a perfect spirit level/bubble level app
Starting with...
window.addEventListener("deviceorientation", handleDeviceTilt);
function handleDeviceTilt(event){
// Here we can use event.beta, event.gamma
// Note that we don't need event....
0
votes
0
answers
21
views
Rotate object against device alpha rotation
I am trying to let an element rotate the opposite of the device rotation like this:
let video = document.getElementById("video");
window.addEventListener("deviceorientation", ...
0
votes
1
answer
47
views
Is it possible to add iPad parameter "deviceOrientation" in testcafe-browser-provider-saucelabs?
My team follows this example for our browser configuration on Saucelabs:
https://github.com/saucelabs/testcafe-browser-provider-ios
To be exact, this is what we have in our code:
"test-ipad":...
0
votes
1
answer
35
views
Logic to know if device orientation is is inline with coordinates
Playing around with some of the browser API's around geolocation and device orientation.
If I know the persons orientation (think compass 0 - 360 degree) is it possible to know if they are pointing ...
0
votes
1
answer
171
views
Detect if device auto orientation mode turned on or off in Flutter
I'm working on this app that uses a video player. In here I use 2 main options to change the orientation of the player, which are the fullscreen button, and the auto rotation feature (changes ...
0
votes
0
answers
15
views
Swift detect when a view's orientation has already changed [duplicate]
I need to detect the orientation of a view changes from landscape to portrait and vice versa. When that rotation happens, I need to execute some logic that requires some layout information of the new ...
0
votes
0
answers
24
views
Direction when device is held vertically
I am building an android app and I use rotation vector sensor to compute the device's position. I need to calculate the angle between a point (location) and the direction to which the rear camera ...
1
vote
0
answers
117
views
How to make a specific screen to appear in landscape mode (for example play video) whereas others are locked in portrait mode in react native?
Here is the code snippet that I have used, but it is not working. It is displaying in portrait mode only
This is a code which I have used for running a video
let w = useWindowDimensions().width;
let h ...
0
votes
0
answers
50
views
Draw UIMenu without observing deviceOrientation - Swift
I'm trying to implement UIMenus when long-pressing on a certain button of my swift app. I'm building a camera app with a .portrait only device orientation.
However, UIMenu will always show for this ...
0
votes
1
answer
235
views
Android | Navigation Graph | Orientation Change | Fragment not retained
General:
I have my app consisting of the activity and several fragments. I am using the Navigation Graph to move through the various fragments. I have the ability to rotate the device and therefore ...
0
votes
1
answer
338
views
how to handle view rotations like youtube do on android?
I want to achieve the way youtube handles its video orientation.
There are a few things to have in mind before just saying that I have to use onConfigurationChanged.
THINGS TO CONSIDER
The phone ...
0
votes
1
answer
116
views
SwiftUI onAppear not working properly when trying to read UIKit's UIDevice orientation
Using iOS14.4.2, Swfit5.3.2, XCode12.4, physical device = iPhoneXS
On appearing, I am trying to write the current device orientation into a Static property and later use it inside a View.
However, the ...
1
vote
0
answers
171
views
Aframe/Three/WebXR: disable device orientation in VR mode
I am using AFrame 1.2.0 to develop a VR application and I am struggling with an issue for several days.
My goal is to allow the user to see a specific view that is set programmatically and that is ...
1
vote
1
answer
607
views
Calling function from outside window.EventListener
So I am trying to call a function outside of my
window.addEventListener('deviceorientation', function (event) {
console.log(event.alpha + ' : ' + event.beta + ' : ' + event.gamma);
...
0
votes
1
answer
280
views
How to resize bootstrap modal for small devices (for landscape and portrait orientations)
I am using angular application created the dashboard page for mobile divices I have written the following for forcible orientation from portrait to landscape for this I have used bootstrap modal
....
0
votes
1
answer
102
views
Google Play pre-launch report screenshots have incorrect orientation
My game uses a fixed portrait orientation. I have personally tested on a couple phones and a tablet. I have never seen issues with my code; the game always has a fixed, forced portrait render.
However,...
1
vote
0
answers
174
views
How to simulate device turning via chrome devtools
For studying purposes i'm trying to interact with a mobile version of a website using JS.
I'm clicking on buttons, filling fields, submiting forms and so on.
But there is a specific feature on this ...
2
votes
1
answer
737
views
Flutter Pageview loses index on orientation change
There have been similar issues recently, but they have been resolved and closed on GitHub.
As I'm a newbie, I could be missing something here.
After an orientation change, the page index reverts to ...
1
vote
0
answers
647
views
React Native (Expo) - useWindowDimensions().width not updated on orientation change
I'm stuck with element sizes based on screen sizes when device orientation changes.
Here's my code
import React, { useEffect, useState } from 'react';
import { View, Text, TouchableOpacity, ...
0
votes
0
answers
269
views
Three.js DeviceOrientationControl makes scene disappear
I have a glb model which loads successfully and reacts to mouse movements. However when I add DeviceOrientationControl.js which is intended for mobile devices, the scene disappears. No errors visible ...
2
votes
4
answers
758
views
Why when I try to use react native hooks it does not work properly as intended to be?
I am developing an app using react native, when I try to console.log(useDeviceOrientation());. The output (true/false) during the portrait and landscape did not change. Could someone help?
The library ...
0
votes
2
answers
131
views
How to get device rotation for iPhone 7 in javascript?
I want to get the device rotation for (alpha, beta, gamma) for iPhone 7 and higher. For iPhone 6 this works well for me:
window.addEventListener('deviceorientation', function(event) {
console.log(...
2
votes
1
answer
1k
views
Three.js THREE.DeviceOrientationControls is not a constructor
I have a problem with ThreeJS giving me this error message. I included all the necessary ThreeJS files but still this message appears. My intention is to have a mobile device navigating with ...
1
vote
1
answer
717
views
Node wss Websocket works on Desktop, not on Mobile
I'm trying to get my phone's orientation data to send to a local server via node's WebSocket (ws) library. In my research, it seems that orientation data is only accessible using ssl, so this will ...
0
votes
1
answer
130
views
How to update theme when device orientation changes
I am trying to implement orientation changing with hooks. I called the orientation hook from app.tsx and I want to update everything(theme,style in component) that uses widthPercentageToDP() function. ...
1
vote
1
answer
274
views
How can I block rotation to only allow portrait mode in xamarin forms?
I need to block rotation on a specific page and this has to work both for Android and iOS.
I tried using NuGet Plugin.DeviceOrientation and adding the following code
protected override void ...
2
votes
0
answers
235
views
How from two deviceorientation events can I find relative roll and pitch for controlling a 2D game
I am making a 2D maze game for mobile using the device orientation as controls. After reading https://developer.mozilla.org/en-US/docs/Web/API/Detecting_device_orientation it seemed pretty simple to ...
0
votes
0
answers
136
views
The orientation in .jpg file is not honored in FireMonkey TWebBrowser
I got help from Peter Wolf last week to rotate a photo in TWebBrowser. Now I am trying to further take the advantage of orientation. The following is a simple photo in portrait mode. It is loaded ...
0
votes
0
answers
156
views
Flutter: Device orientation doesn't dispose in Splash Screen
I used custom device orientation on my splash screen (it's worked) and try to back it normal by use dispose(). But it doesn't work.
Here is my Code-
import 'dart:async';
import 'package:flutter/...
1
vote
1
answer
310
views
Deviceorientaion event isn't working on Chrome on Android
So basically, the deviceorientation event, when the page is running on Android Chrome, doesn't seem to work. The event handler function is never called.
Now the weird thing is that when the same code ...
2
votes
0
answers
35
views
onHeadingChange(event) getting single value for geometrically opposite positions
I am working on android device orientation and getting same values of event.alpha (270) in following positions as shared in image.
i am using following code:
// called on device orientation change
...
1
vote
1
answer
202
views
A-Frame look-controls very unstable on older devices
I'm building a 360 panorama viewer with A-Frame 1.0.4 and I'm having some trouble with older devices that I don't know how to solve. I'm testing in a WebView inside an Android application.
On most ...
3
votes
3
answers
369
views
Flutter Get True DeviceOrientation
I'm using the lines below to get the device orientation
if (MediaQuery.of(context).orientation == Orientation.landscape) // Landscape
{
// Do Something
}
else // Portrait
{
// Do ...
1
vote
1
answer
558
views
How do I make android activity orientation stick to starting value?
Before we start, this is not a duplicate of this older question: Android: How to stick to the same orientation the Activity started with, my use case is a little more specific and new options became ...
0
votes
1
answer
54
views
How to get device orientation correctly after main plugin deprecation
I need to get the device orientation to make some kind of compass. I saw that the old plugin | [2] used for this is now deprecated and that is suggested to use the W3C Device Orientation API now.
I ...
1
vote
3
answers
2k
views
Force landscape orientation in one View
In my App all Views are forced to portrait orientation via info.plist.
The exception should be "MyView" which should always be in landscape orientation.
What I did after taking a deeper look in SO:
...
1
vote
1
answer
505
views
Devicemotion event on iOS
I want to implement mobile device "shake" event both for Android and iOS platforms on my webpage.
So, I immediately found one and only script written by Alex Gibson.
After some tests I found out ...
1
vote
2
answers
844
views
DeviceOrientation Compass Android
I try to implement a compass using the deviceorientation event. I want to use the rotation to rotate an arrow facing in the viewing direction. I'm simply rotating the Image when the deviceorientation ...
0
votes
0
answers
145
views
Android - How to calculate inclination in relevance to a starting position
I calculate the inclination of the device using sensorManager.
SensorManager.getRotationMatrix(Rmat, Imat, gData, mData);
SensorManager.getOrientation(Rmat, orientation)
float incl = SensorManager....
0
votes
2
answers
38
views
Is it acceptable to create an SKShapeNode in update delegate?
I create an SKShapeNode in SpriteKit's update delegate and it works exactly as I want it to. My only concern is that update is called every tenth of a second. Does that mean that my code is also run ...
3
votes
0
answers
187
views
DeviceOrientationEvent.askPermission() not prompting anything
I want access to the accelerometer data on a phone.
In iOS 13 you must expressly ask for permission to get that data.
My dev setup is running webpack-dev-server using --https, testing on my local ...
0
votes
1
answer
752
views
Can't force rotate of orientation in landscape mode
My entire app is portrait mode. However, one screen needs to be able to rotate to landscape (for playing video). I am able to enable all orientation rotations with no problem via @Jonathan Danek's ...