Alejandro Toledo 5 년 전
부모
커밋
973f09a848

+ 9 - 9
inspector/src/components/actionTabs/tabs/propertyGrids/animations/animationCurveEditorComponent.tsx

@@ -164,10 +164,10 @@ export class AnimationCurveEditorComponent extends React.Component<IAnimationCur
         let det=0.0;
         let q1: Vector2 = new Vector2();
         let q2: Vector2 = new Vector2();
-        let ControlA: Vector2 = p0;
-        let ControlB: Vector2 = new Vector2();
-        let ControlC: Vector2 = new Vector2();
-        let ControlD: Vector2 = p3;
+        let controlA: Vector2 = p0;
+        let controlB: Vector2 = new Vector2();
+        let controlC: Vector2 = new Vector2();
+        let controlD: Vector2 = p3;
 
         if ( (u<=0.0) || (u>=1.0) || (v<=0.0) || (v>=1.0) || (u>=v) ){
             return undefined;
@@ -186,13 +186,13 @@ export class AnimationCurveEditorComponent extends React.Component<IAnimationCur
         q2.y = p2.y - ( (1-v)*(1-v)*(1-v)*p0.y + v*v*v*p3.y );
 
 
-        ControlB.x = (d*q1.x - b*q2.x)/det;
-        ControlB.y = (d*q1.y - b*q2.y)/det;
+        controlB.x = (d*q1.x - b*q2.x)/det;
+        controlB.y = (d*q1.y - b*q2.y)/det;
 
-        ControlC.x = ((-c)*q1.x + a*q2.x)/det;
-        ControlC.y = ((-c)*q1.y + a*q2.y)/det;
+        controlC.x = ((-c)*q1.x + a*q2.x)/det;
+        controlC.y = ((-c)*q1.y + a*q2.y)/det;
 
-        return [ControlA, ControlB, ControlC, ControlD];
+        return [controlA, controlB, controlC, controlD];
 
     }
 

+ 10 - 47
inspector/src/components/actionTabs/tabs/propertyGrids/animations/popupComponent.tsx

@@ -1,5 +1,6 @@
 import * as React from "react";
 import * as ReactDOM from 'react-dom';
+import { Inspector } from '../../../../../inspector';
 
 interface IPopupComponentProps {
     id: string,
@@ -11,36 +12,9 @@ interface IPopupComponentProps {
 
 export class PopupComponent extends React.Component<IPopupComponentProps, { isComponentMounted: boolean, blockedByBrowser: boolean }> {
 
-    private _container: HTMLDivElement;
+    private _container: HTMLDivElement | null;
     private _window: Window | null;
 
-    private _CopyStyles(sourceDoc: HTMLDocument, targetDoc: HTMLDocument) {
-        for (var index = 0; index < sourceDoc.styleSheets.length; index++) {
-            var styleSheet: any = sourceDoc.styleSheets[index];
-            try {
-                if (styleSheet.cssRules) { // for <style> elements
-                    const newStyleEl = sourceDoc.createElement('style');
-
-                    for (var cssRule of styleSheet.cssRules) {
-                        // write the text of each rule into the body of the style element
-                        newStyleEl.appendChild(sourceDoc.createTextNode(cssRule.cssText));
-                    }
-
-                    targetDoc.head!.appendChild(newStyleEl);
-                } else if (styleSheet.href) { // for <link> elements loading CSS from a URL
-                    const newLinkEl = sourceDoc.createElement('link');
-
-                    newLinkEl.rel = 'stylesheet';
-                    newLinkEl.href = styleSheet.href;
-                    targetDoc.head!.appendChild(newLinkEl);
-                }
-            } catch (e) {
-                console.log(e);
-            }
-
-        }
-    }
-
     constructor(props: IPopupComponentProps) {
         super(props);
 
@@ -60,28 +34,16 @@ export class PopupComponent extends React.Component<IPopupComponentProps, { isCo
     }
 
     openPopup() {
-        const { title, size, onOpen, onClose } = this.props
 
-        const windowCreationOptionsList = {
-            width: size.width,
-            height: size.height,
-            top: (window.innerHeight - size.width) / 2 + window.screenY,
-            left: (window.innerWidth - size.height) / 2 + window.screenX
-        };
+        const { title, size, onClose, onOpen } = this.props;
 
-        var windowCreationOptions = Object.keys(windowCreationOptionsList)
-            .map(
-                (key) => key + '=' + (windowCreationOptionsList as any)[key]
-            )
-            .join(',');
+        let windowVariableName = `window_${title}`;
 
-        this._window = window.open("", title, windowCreationOptions);
+        this._container = Inspector._CreatePopup(title, windowVariableName, size.width, size.height);
+
+        this._window = (Inspector as any)[windowVariableName];
 
         if (this._window) {
-            this._window.document.title = title;
-            this._CopyStyles(window.document, this._window.document);
-            this._window.document.body.innerHTML = "";
-            this._window.document.body.appendChild(this._container);
             onOpen(this._window);
             this._window.addEventListener('beforeunload', () => this._window && onClose(this._window));
 
@@ -106,8 +68,9 @@ export class PopupComponent extends React.Component<IPopupComponentProps, { isCo
     }
 
     render() {
-        if (!this.state.isComponentMounted) return null
-        return ReactDOM.createPortal(this.props.children, this._container)
+        if (!this.state.isComponentMounted || this._container === null) return null
+        return ReactDOM.createPortal(this.props.children, this._container);
+
     }