Re: [vibra] Vibration API -- the first stab (was: Mozilla's WebVibrator contribution)

On 28.10.2011, at 12.32, ext Dominique Hazael-Massieux wrote:

> Le jeudi 27 octobre 2011 à 18:38 +0300, Anssi Kostiainen a écrit :
>> Here's the first draft of the Vibration API spec as promised:
>>  http://dev.w3.org/2009/dap/vibration/
> 
> Thanks for getting this started!
> 
>> It's basically Mozilla's implementation, with the following changes and some clarifications:
>> * vibrate() is exposed on navigator.vibration instead of navigator
> 
> navigator.vibration.vibrate seems a bit redundant; but I guess that's as
> good a strawman as any other proposal :)

Yes, it's a placeholder, and not the best one especially if we want to supplement the interface in the future with other tactile feedback mechanisms.

I'd suggest we mentally say s/vibration/foo/ so that we do not invest too much energy into naming discussions -- yet :)

>> * two event handlers added: onvibrationstart and onvibrationend
> 
> What are the use cases for these events?

This comes from a game developer:

  https://bugzilla.mozilla.org/show_bug.cgi?id=679966#c25 

Paul Bakaus doesn't mention any use cases, but I could see how having a one-to-many dependency between the vibration and other objects could be useful. For example, lets say there are N angry trolls on the screen, and each of the trolls acts differently when the device vibrates. Being able to notify N objects automatically seems useful.

>> * the exceptions raised by vibrate() are 'SyntaxError' and 'NotSupportedError'
> 
> I think the SyntaxError exception is not needed, since Web IDL gives use
> TypeError for free in these cases.


That'd be great. How would you describe that in WebIDL exactly? Mozilla's implementation states:

[[

 * - If the argument is a list (or if we wrapped it as a list above), then we
 *   try to convert each element in the list to an integer, by first
 *   converting it to a number and then rounding.  If we cannot convert any
 *   element to an integer, or if any of the integers are negative, we throw
 *   an illegal value exception.

]]

Thanks for the feedback!

-Anssi

Received on Friday, 28 October 2011 12:03:11 UTC