Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
2819c279
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2819c279
编写于
5月 22, 2020
作者:
P
Peter Pan
提交者:
GitHub
5月 22, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pref: only get images which are in viewport to reduce backend pressure (#642)
上级
41aacacb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
3 deletion
+25
-3
frontend/packages/core/components/SamplesPage/SampleChart.tsx
...tend/packages/core/components/SamplesPage/SampleChart.tsx
+25
-3
未找到文件。
frontend/packages/core/components/SamplesPage/SampleChart.tsx
浏览文件 @
2819c279
...
@@ -147,9 +147,31 @@ const SampleChart: FunctionComponent<SampleChartProps> = ({run, tag, brightness,
...
@@ -147,9 +147,31 @@ const SampleChart: FunctionComponent<SampleChartProps> = ({run, tag, brightness,
}
}
},
[
step
,
cacheImageSrc
]);
},
[
step
,
cacheImageSrc
]);
const
[
viewed
,
setViewed
]
=
useState
<
boolean
>
(
false
);
const
container
=
useRef
<
HTMLDivElement
>
(
null
);
const
observer
=
useRef
(
process
.
browser
?
new
IntersectionObserver
(
entries
=>
{
if
(
entries
[
0
].
intersectionRatio
>
0
)
{
setViewed
(
true
);
observer
.
current
?.
disconnect
();
}
})
:
null
);
useEffect
(()
=>
{
const
o
=
observer
.
current
;
if
(
process
.
browser
&&
container
.
current
&&
o
)
{
o
.
observe
(
container
.
current
);
return
()
=>
o
.
disconnect
();
}
},
[]);
const
Content
=
useMemo
(()
=>
{
const
Content
=
useMemo
(()
=>
{
// show loading when deferring
// show loading when deferring
if
(
loading
||
!
cached
.
current
[
step
])
{
if
(
loading
||
!
cached
.
current
[
step
]
||
!
viewed
)
{
return
<
GridLoader
color
=
{
primaryColor
}
size
=
"10px"
/>;
return
<
GridLoader
color
=
{
primaryColor
}
size
=
"10px"
/>;
}
}
if
(
!
data
&&
error
)
{
if
(
!
data
&&
error
)
{
...
@@ -159,7 +181,7 @@ const SampleChart: FunctionComponent<SampleChartProps> = ({run, tag, brightness,
...
@@ -159,7 +181,7 @@ const SampleChart: FunctionComponent<SampleChartProps> = ({run, tag, brightness,
return
<
span
>
{
t
(
'
common:empty
'
)
}
</
span
>;
return
<
span
>
{
t
(
'
common:empty
'
)
}
</
span
>;
}
}
return
<
Image
ref
=
{
image
}
src
=
{
src
}
cache
=
{
cacheValidity
}
/>;
return
<
Image
ref
=
{
image
}
src
=
{
src
}
cache
=
{
cacheValidity
}
/>;
},
[
loading
,
error
,
data
,
step
,
src
,
t
]);
},
[
viewed
,
loading
,
error
,
data
,
step
,
src
,
t
]);
return
(
return
(
<
Wrapper
>
<
Wrapper
>
...
@@ -170,7 +192,7 @@ const SampleChart: FunctionComponent<SampleChartProps> = ({run, tag, brightness,
...
@@ -170,7 +192,7 @@ const SampleChart: FunctionComponent<SampleChartProps> = ({run, tag, brightness,
<
StepSlider
value
=
{
step
}
steps
=
{
steps
}
onChange
=
{
setStep
}
onChangeComplete
=
{
cacheImageSrc
}
>
<
StepSlider
value
=
{
step
}
steps
=
{
steps
}
onChange
=
{
setStep
}
onChangeComplete
=
{
cacheImageSrc
}
>
{
formatTime
(
wallTime
*
1000
,
i18n
.
language
)
}
{
formatTime
(
wallTime
*
1000
,
i18n
.
language
)
}
</
StepSlider
>
</
StepSlider
>
<
Container
brightness
=
{
brightness
}
contrast
=
{
contrast
}
fit
=
{
fit
}
>
<
Container
ref
=
{
container
}
brightness
=
{
brightness
}
contrast
=
{
contrast
}
fit
=
{
fit
}
>
{
Content
}
{
Content
}
</
Container
>
</
Container
>
<
ChartToolbox
<
ChartToolbox
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录