npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nativescript-coremotion

v0.1.7

Published

iOS Core Motion plugin for NativeScript

Downloads

5

Readme

NativeScript Core Motion Plugin

Core Motion plugin for NativeScript

Installation

tns plugin add nativescript-coremotion

Usage

var Coremotion = require('nativescript-coremotion');

Accelerometer

isAccelerometerAvailable()

Will return a boolean indicating of the current device supports the accelerometer.

Coremotion.isAccelerometerAvailable()

isAccelerometerActive()

Will return a boolean indicating if Core Motion is currently returning accelerometer data.

Coremotion.isAccelerometerActive()

setAccelerometerUpdateInterval()

Accepts a number, allows changes to the update interval in seconds.

Coremotion.setAccelerometerUpdateInterval(.2);

startAccelerometerUpdates()

Accepts a callback that returns acceleration as the following:

{x, y, z}

Coremotion.startAccelerometerUpdates(callback);

stopAccelerometerUpdates()

Stops Core Motion from sending accelerometer updates.

Coremotion.stopAccelerometerUpdates()

Gyroscope

isGyroscopeAvailable()

Will return a boolean indicating of the current device supports the gyroscope.

Coremotion.isGyroscopeAvailable()

isGyroscopeActive()

Will return a boolean indicating if Core Motion is currently returning gyroscope data.

Coremotion.isGyroscopeActive()

setGyroscopeUpdateInterval()

Accepts a number, allows changes to the update interval in seconds.

Coremotion.setGyroscopeUpdateInterval(.2);

startGyroscopeUpdates()

Accepts a callback that returns rotationRate as the following:

{x, y, z}

Coremotion.startGyroscopeUpdates(callback);

stopGyroscopeUpdates()

Stops Core Motion from sending gyroscope updates.

Coremotion.stopGyroscopeUpdates()

Magnetrometer

isMagnetometerAvailable()

Will return a boolean indicating of the current device supports the magnetometer.

Coremotion.isMagnetometerAvailable()

isMagnetometerActive()

Will return a boolean indicating if Core Motion is currently returning magnetometer data.

Coremotion.isMagnetometerActive()

setMagnetometerUpdateInterval()

Accepts a number, allows changes to the update interval in seconds.

Coremotion.setMagnetometerUpdateInterval(.2);

startMagnetometerUpdates()

Accepts a callback that returns magneticField as the following:

{x, y, z}

Coremotion.startMagnetometerUpdates(callback);

stopMagnetometerUpdates()

Stops Core Motion from sending magnetometer updates.

Coremotion.stopMagnetometerUpdates()

DeviceMotion

isDeviceMotionAvailable()

Will return a boolean indicating of the current device supports deviceMotion.

Coremotion.isDeviceMotionAvailable()

isDeviceMotionActive()

Will return a boolean indicating if Core Motion is currently returning deviceMotion data.

Coremotion.isDeviceMotionActive()

setDeviceMotionUpdateInterval()

Accepts a number, allows changes to the update interval in seconds.

Coremotion.setDeviceMotionUpdateInterval(.2);

startDeviceMotionUpdates()

Accepts a callback that returns the following:

attitude: {pitch, roll, yaw},

gravity: {x, y, z},

userAcceleration: {x, y, z},

magneticField: { accuracy, field: {x, y, z} },

rotationRate: {x, y, z}

Coremotion.startDeviceMotionUpdates(callback);

stopDeviceMotionUpdates()

Stops Core Motion from sending deviceMotion updates.

Coremotion.stopDeviceMotionUpdates()

Altimeter

isRelativeAltitudeAvailable()

Will return a boolean indicating of the current device supports Relative Altitude.

Coremotion.isRelativeAltitudeAvailable()

isRelativeAltitudeActive()

Will return a boolean indicating if Core Motion is currently returning Relative Altitude data.

Coremotion.isRelativeAltitudeActive()

startRelativeAltitudeUpdates()

Accepts a callback that returns the following:

{pressure, relativeAltitude}

Coremotion.startRelativeAltitudeUpdates(callback);

stopDeviceMotionUpdates()

Stops Core Motion from sending Relative Altitude updates.

Coremotion.stopRelativeAltitudeUpdates()

Notes

Plugin is iOS only as Core Motion does not exist on Android.

Plugin requires NativeScript 2.3.0 or higher, well, because it works on that.

Plugin was tested against iOS 10 using Xcode 8.

There was an existing nativescript-accelerometer that only exposed a small subset of Core Motion, would have made PRs against it if the namespace would have permitted.

The isXYZActive() does not re-query Core Motion at this time, but simply returns a boolean set in the plugin.

Warranty

There is none. You accept any and all responsiblity and liability that comes with putting this into your app. Additionally, you agree to pay my legal bills if you use this and someone sues me because it was in your app.