Problem about code to make a map not work in firefox

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
billgate2015
Posts: 12
Joined: August 19th, 2015, 1:01 am
Location: tech
Contact:

Problem about code to make a map not work in firefox

Post by billgate2015 »

Hello all member!
The following code is supposed to make a map on a web page be the only element that is displayed on the page when the phone is turned sideways, and then re-adds the other elements when the phone is turned back to it's original portrait orientation. This works in Chrome for Android but does not work in FireFox v39 for Android.

The first alert fires in FireFox, so I know that device orientation is supported, but the second alert never fires in FireFox, so there is something wrong with my second conditional.

Code: Select all

if (window.DeviceOrientationEvent) {
        alert("supported");
        window.addEventListener('deviceorientation', function (eventData) {
            if (window.orientation == 90 || window.orientation == -90) {
                alert("90 or -90");
                $("#mapTop").css("display", "none");
                $("#mapBottom").css("display", "none");
            }
            else {
                $("#mapTop").css("display", "block");
                $("#mapBottom").css("display", "block");
            }
        });
    }

Thank You Very much!
Have a nice day!
User avatar
DanRaisch
Moderator
Posts: 127188
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: Problem about code to make a map not work in firefox

Post by DanRaisch »

Moving to Web Development.
User avatar
Frenzie
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium
Contact:

Re: Problem about code to make a map not work in firefox

Post by Frenzie »

Why not just console.log the eventData?

Anyhoo, MDN has https://developer.mozilla.org/en-US/doc ... rientation
Intelligent alien life does exist, otherwise they would have contacted us.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: Problem about code to make a map not work in firefox

Post by jscher2000 »

Does your Firefox recognize window.orientation at all?

You could try window.screen.orientation (actually mozOrientation for now), it seems simpler than reading angles:

https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation
User avatar
James
Moderator
Posts: 27999
Joined: June 18th, 2003, 3:07 pm
Location: Made in Canada

Re: Problem about code to make a map not work in firefox

Post by James »

This same posting is posted on a number of other sites in last while.
Post Reply