本文整理汇总了TypeScript中messaging/ui/actions.scrollTo函数的典型用法代码示例。如果您正苦于以下问题:TypeScript scrollTo函数的具体用法?TypeScript scrollTo怎么用?TypeScript scrollTo使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scrollTo函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return ({ getState, dispatch }, { router }) => {
const { ui } = getState();
if (ui.isScrolling || !ui.selectedStreamId) {
return;
}
const elements = document.getElementsByClassName('entry');
const scrollY = window.scrollY + SCROLL_OFFSET;
for (let i = 0; i < elements.length; i++) {
const element = elements[i] as HTMLElement;
if (element.offsetTop > scrollY) {
dispatch(uiActions.scrollTo(0, element.offsetTop - SCROLL_OFFSET));
return;
}
}
const y = document.documentElement.scrollHeight - window.innerHeight;
if (window.scrollY === y) {
const stream = dispatch(getSelectedStream);
if (stream && stream.continuation) {
dispatch(streamActions.fetchMoreEntries(stream.streamId, stream.continuation, stream.fetchOptions));
}
} else {
dispatch(uiActions.scrollTo(0, y));
}
};
示例2: dispatch
}
}
} else {
dispatch(streamActions.fetchFullContent(entry.entryId, entry.url));
}
}
};
}
};
export const gotoFirstLine: Command<{}> = {
name: 'Go to first line',
description: 'Scroll to first line.',
defaultParams: {},
action() {
return uiActions.scrollTo(0, 0);
}
};
export const gotoLastLine: Command<{}> = {
name: 'Go to last line',
description: 'Scroll to last line.',
defaultParams: {},
action() {
return uiActions.scrollTo(
0,
document.documentElement.scrollHeight - document.documentElement.clientHeight
);
}
};