Skip to content

Commit

Permalink
perf(DeviceService): start/stop updates based on visibility state
Browse files Browse the repository at this point in the history
  • Loading branch information
speigg committed Apr 21, 2017
1 parent b3d7b09 commit d2f2194
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import {
ViewportMode
} from './view'

import { VisibilityService } from './visibility'

export class DeviceState {
viewport?:CanvasViewport;
subviews?:SerializedSubviewList;
Expand Down Expand Up @@ -145,7 +147,8 @@ export class DeviceService {
constructor(
protected sessionService:SessionService,
protected contextService:ContextService,
protected viewService:ViewService
protected viewService:ViewService,
protected visibilityService:VisibilityService
) {
sessionService.manager.on['ar.device.state'] =
sessionService.manager.on['ar.device.frameState'] = this._onDeviceState.bind(this);
Expand Down Expand Up @@ -217,11 +220,9 @@ export class DeviceService {
// });
// }

this.startUpdates();
this.sessionService.manager.closeEvent.addEventListener(()=>{
this.stopUpdates();
})

this.visibilityService.showEvent.addEventListener(() => this.startUpdates());
this.visibilityService.hideEvent.addEventListener(() => this.stopUpdates());

this._setupVRPresentChangeHandler();
}

Expand Down

0 comments on commit d2f2194

Please sign in to comment.