livebook/assets/js/hooks/scroll_on_update.js
2022-03-19 12:22:36 +01:00

22 lines
323 B
JavaScript

import { scrollToEnd } from "../lib/utils";
/**
* A hook used to scroll to the bottom of an element whenever it
* receives LV update.
*/
const ScrollOnUpdate = {
mounted() {
this.scroll();
},
updated() {
this.scroll();
},
scroll() {
scrollToEnd(this.el);
},
};
export default ScrollOnUpdate;