Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
9cd00671
Commit
9cd00671
authored
Dec 19, 2018
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add min/max height when resizing and replace debounce with throttle
parent
a007730f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
public/app/features/dashboard/dashgrid/PanelResizer.tsx
+20
-8
No files found.
public/app/features/dashboard/dashgrid/PanelResizer.tsx
View file @
9cd00671
import
React
,
{
PureComponent
}
from
'react'
;
import
{
debounce
,
throttle
}
from
'lodash'
;
import
{
throttle
}
from
'lodash'
;
import
Draggable
from
'react-draggable'
;
import
{
PanelModel
}
from
'../panel_model'
;
...
...
@@ -17,8 +17,8 @@ interface State {
export
class
PanelResizer
extends
PureComponent
<
Props
,
State
>
{
initialHeight
:
number
=
Math
.
floor
(
document
.
documentElement
.
scrollHeight
*
0.4
);
prevEditorHeight
:
number
;
debounc
edChangeHeight
:
(
height
:
number
)
=>
void
;
debounc
edResizeDone
:
()
=>
void
;
throttl
edChangeHeight
:
(
height
:
number
)
=>
void
;
throttl
edResizeDone
:
()
=>
void
;
constructor
(
props
)
{
super
(
props
);
...
...
@@ -28,13 +28,25 @@ export class PanelResizer extends PureComponent<Props, State> {
editorHeight
:
this
.
initialHeight
,
};
this
.
debounc
edChangeHeight
=
throttle
(
this
.
changeHeight
,
20
,
{
trailing
:
true
});
this
.
debouncedResizeDone
=
debounc
e
(()
=>
{
this
.
throttl
edChangeHeight
=
throttle
(
this
.
changeHeight
,
20
,
{
trailing
:
true
});
this
.
throttledResizeDone
=
throttl
e
(()
=>
{
panel
.
resizeDone
();
},
200
);
},
50
);
}
get
largestHeight
()
{
return
document
.
documentElement
.
scrollHeight
*
0.9
;
}
get
smallestHeight
()
{
return
100
;
}
changeHeight
=
height
=>
{
const
sh
=
this
.
smallestHeight
;
const
lh
=
this
.
largestHeight
;
height
=
height
<
sh
?
sh
:
height
;
height
=
height
>
lh
?
lh
:
height
;
this
.
prevEditorHeight
=
this
.
state
.
editorHeight
;
this
.
setState
({
editorHeight
:
height
,
...
...
@@ -43,8 +55,8 @@ export class PanelResizer extends PureComponent<Props, State> {
onDrag
=
(
evt
,
data
)
=>
{
const
newHeight
=
this
.
state
.
editorHeight
+
data
.
y
;
this
.
debounc
edChangeHeight
(
newHeight
);
this
.
debounc
edResizeDone
();
this
.
throttl
edChangeHeight
(
newHeight
);
this
.
throttl
edResizeDone
();
};
render
()
{
...
...
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