diff --git a/css/milkdrop-window.css b/css/milkdrop-window.css
new file mode 100644
index 00000000..f5638501
--- /dev/null
+++ b/css/milkdrop-window.css
@@ -0,0 +1,8 @@
+.webamp-desktop {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ z-index: -1;
+}
diff --git a/js/components/MilkdropWindow/Desktop.js b/js/components/MilkdropWindow/Desktop.js
new file mode 100644
index 00000000..ee5a1c71
--- /dev/null
+++ b/js/components/MilkdropWindow/Desktop.js
@@ -0,0 +1,22 @@
+import React from "react";
+import ReactDOM from "react-dom";
+
+export default class Desktop extends React.Component {
+ componentWillUnmount() {
+ document.body.removeChild(this._desktopNode);
+ this._desktopNode = null;
+ }
+
+ _getNode() {
+ if (this._desktopNode == null) {
+ this._desktopNode = document.createElement("div");
+ this._desktopNode.classList.add("webamp-desktop");
+ document.body.appendChild(this._desktopNode);
+ }
+ return this._desktopNode;
+ }
+
+ render() {
+ return ReactDOM.createPortal(this.props.children, this._getNode());
+ }
+}
diff --git a/js/components/MilkdropWindow/index.js b/js/components/MilkdropWindow/index.js
index 9d902454..7769cbd8 100644
--- a/js/components/MilkdropWindow/index.js
+++ b/js/components/MilkdropWindow/index.js
@@ -2,18 +2,26 @@ import React from "react";
import screenfull from "screenfull";
import ContextMenuWrapper from "../ContextMenuWrapper";
import MilkdropContextMenu from "./MilkdropContextMenu";
+import Desktop from "./Desktop";
import Presets from "./Presets";
import Milkdrop from "./Milkdrop";
import Background from "./Background";
+import "../../../css/milkdrop-window.css";
+
// This component is just responsible for loading dependencies.
// This simplifies the inner component, by allowing
// it to alwasy assume that it has it's dependencies.
export default class PresetsLoader extends React.Component {
constructor() {
super();
- this.state = { presets: null, butterchurn: null, isFullscreen: false };
+ this.state = {
+ presets: null,
+ butterchurn: null,
+ isFullscreen: false,
+ desktop: false
+ };
this._handleFullscreenChange = this._handleFullscreenChange.bind(this);
this._handleRequestFullsceen = this._handleRequestFullsceen.bind(this);
}
@@ -58,9 +66,23 @@ export default class PresetsLoader extends React.Component {
const { butterchurn, presets } = this.state;
const loaded = butterchurn != null && presets != null;
- const width = this.state.isFullscreen ? screen.width : this.props.width;
+ let size = { width: this.props.width, height: this.props.height };
+ if (this.state.isFullscreen) {
+ size = { width: screen.width, height: screen.height };
+ } else if (this.state.desktop) {
+ size = { width: window.innerWidth, height: window.innerHeight };
+ }
- const height = this.state.isFullscreen ? screen.height : this.props.height;
+ const milkdrop = loaded && (
+
+ );
return (
(this._wrapperNode = node)}>
- {loaded && (
-
- )}
+ {this.state.desktop ? {milkdrop} : milkdrop}
);