-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui-manchette: integration manchette + spacetimechart done
- Loading branch information
Showing
5 changed files
with
157 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export const BASE_OP_HEIGHT = 32; | ||
export const BASE_KM_HEIGHT = 8; | ||
export const INITIAL_OP_LIST_HEIGHT = 521; | ||
export const INITIAL_SPACE_TIME_CHART_HEIGHT = INITIAL_OP_LIST_HEIGHT + 40; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { useState, useLayoutEffect, useRef, RefObject } from 'react'; | ||
Check warning on line 1 in ui-manchette/src/hooks/isOverFlowed.ts GitHub Actions / build
|
||
|
||
interface CallbackFunction { | ||
(hasOverflow: boolean): void; | ||
} | ||
|
||
interface CallbackFunction { | ||
(hasOverflow: boolean): void; | ||
} | ||
|
||
export const useIsOverflow = ( | ||
ref: RefObject<HTMLElement>, | ||
callback: CallbackFunction | ||
): boolean | undefined => { | ||
const [isOverflow, setIsOverflow] = useState<boolean | undefined>(undefined); | ||
|
||
useLayoutEffect(() => { | ||
const { current } = ref; | ||
|
||
const trigger = () => { | ||
if (current) { | ||
const hasOverflow = current.scrollHeight > current.clientHeight; | ||
setIsOverflow(hasOverflow); | ||
|
||
if (callback) callback(hasOverflow); | ||
} | ||
}; | ||
|
||
if (current) { | ||
if ('ResizeObserver' in window) { | ||
new ResizeObserver(trigger).observe(current); | ||
} | ||
|
||
trigger(); | ||
} | ||
}, [callback, ref]); | ||
|
||
return isOverflow; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export type Point = { | ||
x: number; | ||
y: number; | ||
}; | ||
|
||
export function getDiff(a: Point, b: Point): Point { | ||
return { | ||
x: b.x - a.x, | ||
y: b.y - a.y, | ||
}; | ||
} |