Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
7c88890f
Commit
7c88890f
authored
May 25, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
May 25, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate observe-element-size module to TS
parent
6df3b42d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
observe-element-size.ts
src/sidebar/util/observe-element-size.ts
+7
-6
No files found.
src/sidebar/util/observe-element-size.
j
s
→
src/sidebar/util/observe-element-size.
t
s
View file @
7c88890f
...
...
@@ -7,13 +7,14 @@ import { ListenerCollection } from '../../shared/listener-collection';
* Returns a cleanup function which should be called to remove observers when
* updates are no longer needed.
*
* @param {Element} element - HTML element to watch
* @param {(width: number, height: number) => void} onSizeChanged -
* Callback to invoke with the `clientWidth` and `clientHeight` of the
* element when a change in its size is detected.
* @return {() => void}
* @param element - HTML element to watch
* @param onSizeChanged - Callback to invoke with the `clientWidth` and
* `clientHeight` of the element when a change in its size is detected.
*/
export
function
observeElementSize
(
element
,
onSizeChanged
)
{
export
function
observeElementSize
(
element
:
Element
,
onSizeChanged
:
(
width
:
number
,
height
:
number
)
=>
void
):
()
=>
void
{
if
(
typeof
ResizeObserver
!==
'undefined'
)
{
const
observer
=
new
ResizeObserver
(()
=>
onSizeChanged
(
element
.
clientWidth
,
element
.
clientHeight
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment