本文整理匯總了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
);
}
};