diff --git a/src/index.tsx b/src/index.tsx
index 45d3f7883..d55b206b7 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -999,6 +999,7 @@ type AppState = {
scrollX: number;
scrollY: number;
name: string;
+ colorPickerPosition: "top" | "bottom";
};
const KEYS = {
@@ -1191,6 +1192,12 @@ function getSelectedBackgroundColor() {
return backgroundColors.length === 1 ? backgroundColors[0] : null;
}
+function getColorPickerPosition(y: number) {
+ // The SketchPicker has a height of 300 px. We determine
+ // if it should be rendered on top of the button or below it.
+ return window.innerHeight - y < 300 ? "top" : "bottom";
+}
+
const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
const ELEMENT_TRANSLATE_AMOUNT = 1;
@@ -1226,7 +1233,8 @@ class App extends React.Component<{}, AppState> {
viewBackgroundColor: "#ffffff",
scrollX: 0,
scrollY: 0,
- name: DEFAULT_PROJECT_NAME
+ name: DEFAULT_PROJECT_NAME,
+ colorPickerPosition: "bottom"
};
private onResize = () => {
@@ -1478,24 +1486,28 @@ class App extends React.Component<{}, AppState> {
Canvas
Canvas Background Color
-
+