-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomOverlayModule.js
More file actions
44 lines (39 loc) · 1.7 KB
/
DomOverlayModule.js
File metadata and controls
44 lines (39 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* The examples provided by Oculus are for non-commercial testing and
* evaluation purposes only.
*
* Oculus reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* OCULUS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import {Module} from 'react-vr-web';
import StickyHeader from './StickyHeader';
// Example implementation of a dom overlay. This is useful on web and mobile,
// whenever a regular, 2D interaction makes more sense than dealing with a 360 scene.
// The key in this module is having a dom element (created in client.js) where our overlay will be rendered.
// What you render is up to you, and you could render as many different overlays as you want from a single module,
// or have multiple native modules, each taking care of a single overlay.
export default class DomOverlayModule extends Module {
constructor(overlayContainer) {
super('DomOverlayModule');
this._closeOverlay = this.closeOverlay.bind(this);
this._overlayContainer = overlayContainer;
}
// This method call opens up the overlay for display.
openOverlay(props) {
ReactDOM.render(
<StickyHeader {...props} onClose={this._closeOverlay} />,
this._overlayContainer
);
}
closeOverlay() {
ReactDOM.unmountComponentAtNode(this._overlayContainer);
}
}