diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingView.tsx | 27 | ||||
-rw-r--r-- | src/client/views/collections/CollectionNoteTakingViewDivider.tsx | 67 |
2 files changed, 72 insertions, 22 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx index 785732659..818c5b671 100644 --- a/src/client/views/collections/CollectionNoteTakingView.tsx +++ b/src/client/views/collections/CollectionNoteTakingView.tsx @@ -26,6 +26,7 @@ import { CollectionNoteTakingViewFieldColumn } from "./CollectionNoteTakingViewF import "./CollectionNoteTakingView.scss"; import { CollectionSubView } from "./CollectionSubView"; import { CollectionViewType } from "./CollectionView"; +import CollectionNoteTakingViewDivider from "./CollectionNoteTakingViewDivider"; const _global = (window /* browser */ || global /* node */) as any; @@ -659,18 +660,22 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti //TODO make this look pretty if (i < sections.length - 1) { eles.push( - <div style={{display: "flex", alignItems: "center", cursor: "col-resize"}}> - <div className="columnDivider" onPointerOver={e => this.onDividerPointerOver(e, i)} key={i} - style={{ - height: "95%", - width: 12, - borderRight: "4px solid #282828", - borderLeft: "4px solid #282828", - margin: "0px 10px" - }} + // <div style={{display: "flex", alignItems: "center", cursor: "col-resize"}}> + // <div className="columnDivider" onPointerOver={e => this.onDividerPointerOver(e, i)} key={i} + // style={{ + // height: "95%", + // width: 12, + // borderRight: "4px solid #282828", + // borderLeft: "4px solid #282828", + // margin: "0px 10px" + // }} + // /> + // </div> + <CollectionNoteTakingViewDivider + index={i} + columnStartXCoords={this.columnStartXCoords} + xMargin={this.xMargin} /> - </div> - ) } } diff --git a/src/client/views/collections/CollectionNoteTakingViewDivider.tsx b/src/client/views/collections/CollectionNoteTakingViewDivider.tsx index 11e1b5d62..9b4af16ce 100644 --- a/src/client/views/collections/CollectionNoteTakingViewDivider.tsx +++ b/src/client/views/collections/CollectionNoteTakingViewDivider.tsx @@ -1,7 +1,5 @@ -import { auto } from "async"; -import { action } from "mobx"; +import { action, observable } from "mobx"; import * as React from "react"; -import { DragManager } from "../../util/DragManager"; interface DividerProps { index: number @@ -10,19 +8,66 @@ interface DividerProps { } export default class Divider extends React.Component<DividerProps>{ - + @observable private isHoverActive = false; + @observable private isResizingActive = false; + @action + private registerResizing = (e: React.PointerEvent<HTMLDivElement>) => { + e.stopPropagation(); + e.preventDefault(); + window.removeEventListener("pointermove", this.onPointerMove); + window.removeEventListener("pointerup", this.onPointerUp); + window.addEventListener("pointermove", this.onPointerMove); + window.addEventListener("pointerup", this.onPointerUp); + this.isResizingActive = true; + } + + @action + private onPointerUp = () => { + this.isResizingActive = false; + this.isHoverActive = false; + window.removeEventListener("pointermove", this.onPointerMove); + window.removeEventListener("pointerup", this.onPointerUp); + } + @action + onPointerMove = ({ movementX }: PointerEvent) => { + // if (DragManager.docsBeingDragged.length == 0) { + // //convert client X to how we're doing stuff + // const xPos = e.clientX + 2 * this.props.xMargin + // // get difference (-25 is because that's the center of the divider) + // const xDividerPos = this.props.columnStartXCoords[this.props.index + 1] - 25 + // const diff = xDividerPos - xPos + // // make a copy of the array + // const colXCoords : number[] = [] + // this.props.columnStartXCoords.forEach(val => colXCoords.push(val)) + this.props.columnStartXCoords[this.props.index + 1] += movementX + console.log(this.props.columnStartXCoords) + // this.props.columnStartXCoords = colXCoords + // } + } + render() { return ( - <div style={{ - height: "100%", - width: 50, - padding: `0 10 10 0`, - margin: "auto", - backgroundColor: "black" + <div className="columnResizer" + style={{ + display: "flex", + alignItems: "center", + cursor: "col-resize" }} - /> + onPointerEnter={action(() => this.isHoverActive = true)} + onPointerLeave={action(() => !this.isResizingActive && (this.isHoverActive = false))} + > + <div className="columnResizer-handler" onPointerDown={e => this.registerResizing(e)} + style={{ + height: "95%", + width: 12, + borderRight: "4px solid #282828", + borderLeft: "4px solid #282828", + margin: "0px 10px" + }} + /> + </div> ) } }
\ No newline at end of file |