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

On Thu, Jul 21, 2011 at 5:39 PM, Doug Turner <doug.turner@gmail.com> wrote:
> Using the Android or IOS device APIs, in this case, I continue to see small amounts of movement.  Maybe this is a theortical question (which I am not very interested in), or there is a lot of noise that isn't filtered out by the platform.  Do you see the same thing, Andrei?
>

Since the device isn't moving, what you are picking up is probably
just noise/drift from the underlying sensors (compass / gyro /
accelerometer). Perhaps the OS should filter that out but, if it
doesn't, I think the UA should do it if it can. I don't think this
noise should trigger Device Orientation events. And if this is the
case, then the "present state" problem is not just a theoretical one.

> In any case, I don't think we want to add different events for "present" state.  Instead, I think it is completely fine to just fire an onchange for new listeners.
>

That's what's in the spec today, but what is your take on the concerns
raised by Anne about addEventListener()?

Thanks,
Andrei



> Doug
>
> On Jul 21, 2011, at 4:40 PM, Andrei Popescu wrote:
>
>> What happens if the device (say, a tablet) is lying still on a table?
>> If I load a Web page that uses this API to show a compass UI, the page
>> won't get any events until I move the tablet around. I'm not sure this
>> is acceptable?
>>
>> Andrei
>>
>> On Thu, Jul 21, 2011 at 3:54 PM, Doug Turner <doug.turner@gmail.com> wrote:
>>> i don't see the point, really.  for device orientation, the interval between movements -- especially on a precise device -- is very small (< .10s).  Because of this, I don't think you need a separate event for the initial value.
>>>
>>>
>>> On Jul 21, 2011, at 3:42 PM, Anne van Kesteren wrote:
>>>
>>>> On Thu, 21 Jul 2011 19:00:45 +0200, Andrei Popescu <andreip@google.com> wrote:
>>>>> 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
>>>>> EventTarget:
>>>>>
>>>>> 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:
>>>>>
>>>>> http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#request-api
>>>>>
>>>>> What do you think?
>>>>
>>>> Looks good to me. If this is synchronous anyway maybe this should just be an attribute.
>>>>
>>>>
>>>>
>>>> --
>>>> Anne van Kesteren
>>>> http://annevankesteren.nl/
>>>>
>>>
>>>
>
>

Received on Friday, 22 July 2011 23:25:55 UTC