device-orientation-manager
Version:
A manager which will help you to control DeviceOrientation easily.
58 lines (57 loc) • 1.8 kB
TypeScript
export declare type TOrientation = 0 | 90 | 180 | -90;
export interface IDeviceOrientationData {
supported: boolean;
orientation: TOrientation;
origOrientation: TOrientation;
order: 'YXZ';
yaw: number;
pitch: number;
roll: number;
}
export declare type TDeviceOrientationEvents = 'orientationchange' | 'deviceorientation';
export default class DeviceOrientationManager {
enableMouseOrTouch: boolean | 'auto';
freq: number;
filterSmoothing: number;
filterWindowSize: number;
container: HTMLElement;
private _emitter;
private _lpf;
private _orientationMode;
private _orientation;
private _deviceSupported;
private _mode;
private _yaw;
private _pitch;
private _started;
private _escapeTime;
private _pointerX;
private _pointerY;
constructor(options?: {
freq?: number;
enableMouseOrTouch?: boolean | 'auto';
container?: HTMLElement;
orientation?: TOrientation | 'auto';
filterSmoothing?: number;
filterWindowSize?: number;
});
orientation: TOrientation | 'auto';
readonly ready: boolean;
readonly current: IDeviceOrientationData;
addEventListener(type: TDeviceOrientationEvents, handler: (data: IDeviceOrientationData) => any): void;
removeEventListener(type: TDeviceOrientationEvents, handler: (data: IDeviceOrientationData) => any): void;
start(): void;
stop(): void;
private initLpf;
private canUseMouseOrTouch;
private handleDeviceOrientation;
private handleOrientationChange;
private handleTouchStart;
private handleTouchMove;
private handleTouchEnd;
private handleMouseDown;
private handleMouseMove;
private handleMouseUp;
private normalizeMouseOrTouch;
private loop;
}