comty/src/core/libs/router/index.js
2020-11-26 14:57:22 +01:00

37 lines
721 B
JavaScript
Executable File

import { history } from 'umi';
export const router = {
push: e => {
history.push({
pathname: `${e}`,
});
},
go: e => {
router.push(e);
},
goProfile: e => {
router.push(`/@/${e}`);
},
};
export const goTo = {
top: id => {
const element = document.getElementById(id);
element.scrollTop = element.scrollHeight + element.clientHeight;
},
bottom: id => {
const element = document.getElementById(id);
element.scrollTop = element.scrollHeight - element.clientHeight;
},
element: element => {
try {
document.getElementById(element).scrollIntoView();
} catch (error) {
console.debug(error);
return false;
}
},
};
export default router