From: Andrzej Popowski Date: Thu, 3 Dec 2015 14:11:48 +0000 (+0100) Subject: [Devicemotion] - fix first data got from accelerometer X-Git-Tag: submit/tizen/20151221.111205^2~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06a8a0abcb0080851fa1cccdb55a60c31d2a55f5;p=platform%2Fcore%2Fapi%2Fcordova-plugins.git [Devicemotion] - fix first data got from accelerometer Change-Id: I947e6ad9d2a239ca7ddc0071d818c4177a8d7e0d Signed-off-by: Andrzej Popowski --- diff --git a/src/devicemotion/cordova_devicemotion_api.js b/src/devicemotion/cordova_devicemotion_api.js index 804cc38..353d0ee 100755 --- a/src/devicemotion/cordova_devicemotion_api.js +++ b/src/devicemotion/cordova_devicemotion_api.js @@ -21,6 +21,7 @@ cordova.define(plugin_name, function(require, exports, module) { // TODO: remove -> end var successCB = null; +var count = 0; function listener(eventData) { var accel = {}; @@ -35,12 +36,17 @@ function listener(eventData) { return; } + if (count++ === 0) { + return; + } + successCB && successCB(accel); } var Accelerometer = { start: function (success, error) { if (!successCB) { + count = 0; successCB = success; window.addEventListener('devicemotion', listener, false); }