Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A8A511E17 for ; Mon, 5 May 2014 16:09:34 +0000 (UTC) Received: (qmail 20592 invoked by uid 500); 5 May 2014 16:09:09 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 20408 invoked by uid 500); 5 May 2014 16:09:06 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 20247 invoked by uid 99); 5 May 2014 16:09:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2014 16:09:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BFF9F91132A; Mon, 5 May 2014 16:09:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mmocny@apache.org To: commits@cordova.apache.org Date: Mon, 05 May 2014 16:09:17 -0000 Message-Id: In-Reply-To: <424589e647314319adf54effbaad4b16@git.apache.org> References: <424589e647314319adf54effbaad4b16@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [17/49] git commit: tweak scoping tweak scoping Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/8a245a57 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/8a245a57 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/8a245a57 Branch: refs/heads/cdvtest Commit: 8a245a57cf90b2fb8c650103826b33d9b46b9b81 Parents: 4a3a33f Author: James Long Authored: Thu Oct 24 19:15:29 2013 -0400 Committer: James Long Committed: Thu Oct 24 19:15:29 2013 -0400 ---------------------------------------------------------------------- src/firefoxos/accelerometer.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/8a245a57/src/firefoxos/accelerometer.js ---------------------------------------------------------------------- diff --git a/src/firefoxos/accelerometer.js b/src/firefoxos/accelerometer.js index 025b6c8..6d22509 100644 --- a/src/firefoxos/accelerometer.js +++ b/src/firefoxos/accelerometer.js @@ -1,12 +1,15 @@ -var listener; + +function listener(success, ev) { + var acc = ev.accelerationIncludingGravity; + acc.timestamp = new Date().getTime(); + success(acc); +} + var Accelerometer = { start: function start(success, error) { - listener = function(ev) { - var acc = ev.accelerationIncludingGravity; - acc.timestamp = new Date().getTime(); - success(acc); - } - return window.addEventListener('devicemotion', listener, false); + return window.addEventListener('devicemotion', function(ev) { + listener(success, ev); + }, false); }, stop: function stop() {