From 4bf88786cc8a7e617bca4eb57f7639d69be06dcd Mon Sep 17 00:00:00 2001
From: andrewdkim <adkim414@gmail.com>
Date: Wed, 15 Jan 2020 17:42:41 -0500
Subject: wow this almost drove me crazy but swipey swipes on five fingers

---
 src/client/views/Palette.tsx | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

(limited to 'src/client/views/Palette.tsx')

diff --git a/src/client/views/Palette.tsx b/src/client/views/Palette.tsx
index aca1811a4..811c24f53 100644
--- a/src/client/views/Palette.tsx
+++ b/src/client/views/Palette.tsx
@@ -9,8 +9,8 @@ import { DocumentView } from "./nodes/DocumentView";
 import { emptyPath, returnFalse, emptyFunction, returnOne, returnEmptyString, returnTrue } from "../../Utils";
 import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils";
 import { Transform } from "../util/Transform";
-import { computed, action } from "mobx";
-import { FieldValue, Cast } from "../../new_fields/Types";
+import { computed, action, IReactionDisposer, reaction, observable } from "mobx";
+import { FieldValue, Cast, NumCast } from "../../new_fields/Types";
 import { observer } from "mobx-react";
 import { DocumentContentsView } from "./nodes/DocumentContentsView";
 import { CollectionStackingView } from "./collections/CollectionStackingView";
@@ -28,12 +28,26 @@ export interface PaletteProps {
 
 @observer
 export default class Palette extends React.Component<PaletteProps> {
+    private _selectedDisposer?: IReactionDisposer;
+    @observable private _selectedIndex: number = 0;
+
+    componentDidMount = () => {
+        this._selectedDisposer = reaction(
+            () => NumCast(this.props.thumbDoc.selectedIndex),
+            (i) => this._selectedIndex = i,
+            { fireImmediately: true }
+        );
+    }
+
+    componentWillUnmount = () => {
+        this._selectedDisposer && this._selectedDisposer();
+    }
 
     render() {
         return (
             <div className="palette-container" style={{ transform: `translate(${this.props.x}px, ${this.props.y}px)` }}>
                 <div className="palette-thumb" style={{ transform: `translate(${this.props.thumb[0] - this.props.x}px, ${this.props.thumb[1] - this.props.y}px)` }}>
-                    <div className="palette-thumbContent">
+                    <div className="palette-thumbContent" style={{ transform: `translate(-${(this._selectedIndex * 50) + 10}px, 0px)` }}>
                         <DocumentView
                             Document={this.props.thumbDoc}
                             DataDoc={undefined}
-- 
cgit v1.2.3-70-g09d2

