Hi! I’m new to using the Observable runtime and have run into a wall:
I have a notebook embedded into a vue app using this approach.
How can I run a function (cell) from inside Vue.js?
More specifically, I want to know if its possible to do something like this:
window.addEventListener("wheel", myNotebookFunc)
function myNotebookFunc(event){
// do something with event.deltaY
}
Tried following this example which redefines a notebook variable on window resize (I think): examples/index.html at main · observablehq/examples · GitHub
main.redefine("height", resizer(container, "height"));
// Rather making separate generators for width and height, here’s a generalized
// generator “factory” that watches the given dimension of the given element.
// (Note: depends on browser ResizeObserver support.)
function resizer(element, dimension) {
return library.Generators.observe(notify => {
let value = notify(element.getBoundingClientRect()[dimension]); // initial value
const observer = new ResizeObserver(([entry]) => {
const newValue = entry.contentRect[dimension];
if (newValue !== value) {
notify(value = newValue);
}
});
observer.observe(element);
return () => observer.disconnect();
});
However, I can’t seem to adapt it to my use case.
Any ideas welcome