// From robb0wen/tornis// import the Tornis store functionsimport{watchViewport,unwatchViewport,getViewportState}from'tornis';// define a watched function, to be run on each updateconstupdateValues=({size,scroll,mouse,orientation})=>{if(size.changed){// do something related to size}if(scroll.changed){// do something related to scroll position or velocity}if(mouse.changed){// do something related to mouse position or velocity}};// bind the watch function// By default this will run the function as it is added to the watch listwatchViewport(updateValues);// to bind the watch function without calling itwatchViewport(updateValues,false);// when you want to stop updatingunwatchViewport(updateValues);// to get a snapshot of the current viewport stateconststate=getViewportState();