W3C home > Mailing lists > Public > public-geolocation@w3.org > July 2011

Re: Spec update: deviceorientation event should fire when listener is first registered

From: Andrei Popescu <andreip@google.com>
Date: Thu, 21 Jul 2011 10:00:45 -0700
Message-ID: <CAGn1-_X2cyz0vY_kq-guWvXdZAtW0G76F2zC8x1NDN05x51NJQ@mail.gmail.com>
To: Anne van Kesteren <annevk@opera.com>
Cc: (wrong string) Å‚owski <wmaslowski@opera.com>, Bjoern Hoehrmann <derhoermi@gmx.net>, public-geolocation <public-geolocation@w3.org>

Thinking about this some more, I was wondering if there's any merit to
the following idea:

- we could have a new "getDeviceOrientation()" method on the navigator
object. This method synchronously returns an object that is an

var o = navigator.getDeviceOrientation();

- this object is then the target of device orientation events:

o.addEventListener("initial", function(event) { ... });
o.addEventListener("change", function...);
o.addEventListener("error", function...);

This design solves the problem by having the "getDeviceOrientation()"
function be the one that triggers the initial event. I think it also
solves the problem brought up by Bjoern. Furthermore, there is a
precedent for this design in the Indexed Database specification:


What do you think?


On Wed, Jul 13, 2011 at 7:23 AM, Andrei Popescu <andreip@google.com> wrote:
> On Wed, Jul 13, 2011 at 2:55 PM, Anne van Kesteren <annevk@opera.com> wrote:
>> On Wed, 13 Jul 2011 15:38:18 +0200, Anne van Kesteren <annevk@opera.com>
>> wrote:
>>> I do not really see how it contradicts it. Setting the attribute does that
>>> *and* causes an event to be dispatched (or starts some process in the case
>>> of MessagePort). The pattern was discussed a while back on the WHATWG list.
>> By the way I am not saying you should use this pattern. Maybe as Björn
>> indicated you need another approach to this API. Have the information
>> hanging off from the Navigator object somewhere and dispatch an event using
>> the basic Event interface when the information has changed.
> Yep, we should discuss that. The basic issue there is that we'd have
> to keep the information fresh on this object, which means always
> exercising the underlying hardware, even if no page is using it.
> Thanks,
> Andrei
Received on Thursday, 21 July 2011 17:01:10 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:51:02 UTC