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

gyronorm-element

v1.0.0

Published

Element wrapper for the gyronorm.js library

Downloads

3

Readme

gyronorm-element

Element wrapper for gyronorm.js, a JavaScrip library that accesses the gyroscope and accelerometer data from the web browser and combines them in one JS object.

This element wraps the gyronorom.js library in an HTML element using Polymer. It exposes the public API of gyronorm.js as attributes and functions.

Below are the details of the HTML element and basic usage. If you want information on the JavaScript version of gyronorm.js, please visit the GitHub page.

Installation

Use Bower or NPM

$ bower install gyronorm-element

or

$ npm install gyronorm-element

How to add

Use the HTML imports to add it to your HTML file.

...

<link rel="import" href="[path to the element]/gyronorm-element.html">

...

How to use

Use the element like any other HTML elements in the <body></body> section.

...

<body>

	<gyronorm-element></gyronorm-element>

</body>

...

When the element is rendered, the gyronorm object is initilized with default values, and start to provide deviceorientation and devicemotion data. So the element is ready to use.

You can use attributes to access this data and/or change the default options.

The attributes and functions are explained below.

Attributes

Gyroscope and accelerometer values

Gyronorm.js provides the values of gyroscope and accelerometer in one object. The wrapper element has attributes to provide these values as separate attributes.

After the element is rendered, the following attributes will update and provide values (every millisecond defined in the frequency attribute.)

You can bind a variable to those attribute on host element. So this variable will reflect the updated values. Below is an example.

<body>

	<gyronorm-element alpha="{{alphaValue}}"></gyronorm-element>

	<paper-input label="alpha" value="[[alphaValue]]" disabled></paper-input>

</body>

Here is a list of these attributes

  • alpha
  • beta
  • gamma
  • acceleration-x
  • acceleration-y
  • acceleration-z
  • gravity-x
  • gravity-y
  • gravity-z
  • rotation-rate-alpha
  • rotation-rate-beta
  • rotation-rate-gamma

Please note that these values are all read-only and can be used only to pass the data from gyronorm-element to the host element.

Log messages

Gyronorm.js library sends log and error messages. The element exposes these messages in an attribute called log-message. You can bind to this attribute and display the messages. Below is an example.

<body>

	<gyronorm-element log-message="{{message}}"></gyronorm-element>

	<paper-input label="Log Message" value="[[message]]" disabled></paper-input>

</body>

Options

The element exposes the initial options of Gyronorm.js as attributes. If you want to learn more about the options and what they do you can check the gyronorm.js README.md

Note that when you change the values of these attributes, the GyroNorm object is stopsed and reinitiated under the hood. Chaging them very frequently might be costly on performance.

Here is a list of attributes and expected values

  • decimal-count (Integer)
  • frequency (Integer)
  • gravity-normalized (Boolean)
  • orientation-base (String - world or game)
  • screen-adjusted (Boolean)

The demo file shows details how you can use those attributes.

Function

The element exposes only one function from the gyronorm object. The rest can be handled with attributes.

setHeadDirection

You can call this only when screen-adjusted is set to false. After it is called, the element will start to return alpha values relative to the current head direction of the device.

<body>

	<gyronorm-element id="gyronorm" alpha="{{alpha}}"></gyronorm-element>

	<paper-input label="alpha" value="[[alpha]]" disabled></paper-input>

	<!-- When youclick this button, the gyronorm-element wil update the head direction -->
	<paper-button class="colorful" onclick="_setHeadDirection()">Set head direction</paper-button>

	<script>

		var _setHeadDirection = function(){

			var gnElement = document.getElementById('gyronorm');
			gnElement.setHeadDirection();

		}

	</script>


</body>