Files
react-native-devtools-frontend/front_end/ui/RootView.js
T
Paul Lewis 50993696be [Global] Update refs to UI.viewManager & UI.zoomManager
Bug: 1006759
Change-Id: Iebf11153861850acbbfef9f40e3552d1be9a6460
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2016760
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
2020-01-23 15:45:11 +00:00

44 lines
1.2 KiB
JavaScript

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {VBox} from './Widget.js';
/**
* @unrestricted
*/
export class RootView extends VBox {
constructor() {
super();
this.markAsRoot();
this.element.classList.add('root-view');
this.registerRequiredCSS('ui/rootView.css');
this.element.setAttribute('spellcheck', false);
}
/**
* @param {!Document} document
*/
attachToDocument(document) {
document.defaultView.addEventListener('resize', this.doResize.bind(this), false);
this._window = document.defaultView;
this.doResize();
this.show(/** @type {!Element} */ (document.body));
}
/**
* @override
*/
doResize() {
if (this._window) {
const size = this.constraints().minimum;
const zoom = self.UI.zoomManager.zoomFactor();
const right = Math.min(0, this._window.innerWidth - size.width / zoom);
this.element.style.marginRight = right + 'px';
const bottom = Math.min(0, this._window.innerHeight - size.height / zoom);
this.element.style.marginBottom = bottom + 'px';
}
super.doResize();
}
}