Skip to content

Commit

Permalink
Fixes and nits addressed, thanks Terry.
Browse files Browse the repository at this point in the history
  • Loading branch information
mulshine committed Oct 23, 2024
1 parent d562ad7 commit b910cd3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/accel/Accel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Accel_ck, AccelMsg_ck } from "./accelCk";
* iOS devices require that the web developer ask permission from the user to access sensors after a button push. For example:
*
* ```ts
* import { Chuck, Accel} from '../webchuck/src/wc-bundle.js';
* import { Chuck, Accel } from "webchuck";
*
* let theChuck = await Chuck.init([]); // context suspended
* let accel = await Accel.init(theChuck);
Expand Down Expand Up @@ -76,7 +76,7 @@ export default class Accel {
await accel.theChuck.runCode(Accel_ck);

// Enable mouse and keyboard
accel.enableAccel();
if (enableAccel) accel.enableAccel();
return accel;
}

Expand Down
16 changes: 7 additions & 9 deletions src/gyro/Gyro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Gyro_ck, GyroMsg_ck } from "./gyroCk";


/**
* Introducing Gyro (gyroerometer, on mobile) support for WebChucK. Gyro wraps
* JavaScript DeviceMotionEvent listeners easing access to mobile device gyroerometers
* Introducing Gyro (gyroscope, on mobile) support for WebChucK. Gyro wraps
* JavaScript DeviceOrientationEvent listeners easing access to mobile device gyroscope
* in WebChucK code.
*
* To get started with Gyro:
Expand All @@ -22,7 +22,7 @@ import { Gyro_ck, GyroMsg_ck } from "./gyroCk";
* iOS devices require that the web developer ask permission from the user to access sensors after a button push. This looks like:
*
* ```ts
* import { Chuck, Gyro} from '../webchuck/src/wc-bundle.js';
* import { Chuck, Gyro } from "webchuck";
*
* let theChuck = await Chuck.init([]); // context suspended
* let gyro = await Gyro.init(theChuck);
Expand Down Expand Up @@ -60,7 +60,7 @@ export default class Gyro {
/**
* Initialize Gyro functionality in your WebChucK instance.
* This adds a `Gyro` and `GyroMsg` class to the ChucK Virtual Machine (VM).
* Gyroerometer event (DeviceMotionEvent) listeners are added if `enableGyro` is true (default).
* Gyrscope event (DeviceOrientationEvent) listeners are added if `enableGyro` is true (default).
* @example
* ```ts
* theChuck = await Chuck.init([]);
Expand All @@ -76,7 +76,7 @@ export default class Gyro {
await gyro.theChuck.runCode(Gyro_ck);

// Enable mouse and keyboard
gyro.enableGyro();
if (enableGyro) gyro.enableGyro();
return gyro;
}

Expand All @@ -92,21 +92,19 @@ export default class Gyro {
}

/**
* Enable Javascript event (DeviceMotionEvent) listeners for Gyro
* Enable Javascript event (DeviceOrientationEvent) listeners for Gyro
* @example
* ```ts
* // If gyro is not yet enabled
* gyro.enableGyro();
* ```
*/
enableGyro() {
// consider using "deviceorientationabsolute"
// https://developer.mozilla.org/en-US/docs/Web/API/Window/deviceorientationabsolute_event
window.addEventListener("deviceorientation", this.boundHandleOrientation);
}

/**
* Disable Javascript event (DeviceMotionEvent) listeners for Gyro
* Disable Javascript event (DeviceOrientationEvent) listeners for Gyro
* @example
* ```ts
* // If gyro is enabled
Expand Down

0 comments on commit b910cd3

Please sign in to comment.