feat: can set rootMargin for IntersectionObserver.
This commit is contained in:
@@ -182,5 +182,5 @@ export const DEFAULT_SETTING = {
|
|||||||
transAllnow: false, // 是否立即全部翻译
|
transAllnow: false, // 是否立即全部翻译
|
||||||
subtitleSetting: DEFAULT_SUBTITLE_SETTING, // 字幕设置
|
subtitleSetting: DEFAULT_SUBTITLE_SETTING, // 字幕设置
|
||||||
logLevel: LogLevel.INFO.value, // 日志级别
|
logLevel: LogLevel.INFO.value, // 日志级别
|
||||||
rootMargin: 200, // 提前触发翻译
|
rootMargin: 500, // 提前触发翻译
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ export class Translator {
|
|||||||
|
|
||||||
// 监控翻译单元的可见性
|
// 监控翻译单元的可见性
|
||||||
#createIntersectionObserver() {
|
#createIntersectionObserver() {
|
||||||
const { transInterval, rootMargin = 200 } = this.#setting;
|
const { transInterval, rootMargin = 500 } = this.#setting;
|
||||||
|
|
||||||
const pending = new Set();
|
const pending = new Set();
|
||||||
const flush = debounce(() => {
|
const flush = debounce(() => {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ export default function Settings() {
|
|||||||
skipLangs = [],
|
skipLangs = [],
|
||||||
// detectRemote = true,
|
// detectRemote = true,
|
||||||
transAllnow = false,
|
transAllnow = false,
|
||||||
rootMargin = 200,
|
rootMargin = 500,
|
||||||
} = setting;
|
} = setting;
|
||||||
const { isHide = false, fabClickAction = 0 } = fab || {};
|
const { isHide = false, fabClickAction = 0 } = fab || {};
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ export default function Settings() {
|
|||||||
value={rootMargin}
|
value={rootMargin}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
min={0}
|
min={0}
|
||||||
max={1000}
|
max={10000}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
{/* <Grid item xs={12} sm={12} md={6} lg={3}>
|
{/* <Grid item xs={12} sm={12} md={6} lg={3}>
|
||||||
|
|||||||
Reference in New Issue
Block a user