livebook/assets/js/hooks/scroll_on_update.js

22 lines
323 B
JavaScript
Raw Normal View History

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;