Skip to content

Breaking changes from 1.x to 2.x

Doruk Eker edited this page Jan 27, 2017 · 17 revisions

How to add

Versions 1.x was accessing the sensors data via the window object directly. Versions 2.x uses FullTilt project for this layer. So there are changes when adding gyronorm.js

For production I suggest to add the minified complete version. It also contains the FullTilt.

<script src="<path_to_js_files>/gyronorm.complete.min.js"></script>

If you want to use the un-minified version of gyronorm.js, you need to add FullTilt manually.

<script src="<path_to_js_files>/fulltilt.min.js"></script>
<script src="<path_to_js_files>/gyronorm.js"></script>

Instantiating and initialising

Versions 1.x: you had to provide a ready() function as a part of the arguments. That function was called when GyroNorm object was ready.

var args = {ready:ongnReady};
var gn = new GyroNorm(args);
var ongnReady = function(){

    // do something here

}

Versions 2.x: You do not have the ready() function. This logic is handled in a promise. Here is the new way of doing it.

var gn = new GyroNorm();
gn.init(args).then(function(){

    // do something here

});

Note that you can still provide arguments to the init() function to overwrite other options. See the API Documentation for details

Options

The options you can pass when initialising has changed.

The following options are removed

directionAbsolute (replaced by the new orientationBase)
ready (replaced with the promise logic described above)

The following options are added. You can check the API Documentation for the default values.

orientationBase
screenAdjusted

Methods

Removed: giveAbsoluteDirection()

The absolute direction is replaced by the orientationBase. The possibilities are game-based or world-based. For now you cannot change this after object is initialised.

Updated: GyroNorm()

The constructor function does not take any arguments anymore. You can pass those arguments in the new init() function.

var args = { ... };
var gn = new GyroNorm();
gn.init(args).then( ... );

#####Updated: setHeadDirection() Now it returns a boolean value. true if it was successful to set the head direction; false if not.