You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm trying to set the space key as the one that triggers the panning functionality. It's a bigger key and i want my visitors to be able to select the text in the content that I'm writing.
I tried a lot of combinations, the one I thought would be the best would be this one: panzoom(element, { beforeMouseDown: function(e) { const shouldIgnore = !(e.altKey || (e.code === 'Space')); return shouldIgnore; }, });
But it doesn't work either. What's the most appropriate way to do that with this library? Thanks
The text was updated successfully, but these errors were encountered:
You need to check if space is pressed first. This is how I solved it:
letspacebarPressed=false;consthandleSpaceBarKeydown=(e: KeyboardEvent)=>{if(e.key===' '||e.code==='Space'){if(document.body===e.target||document.getElementById('scene')===e.target){e.stopPropagation();e.preventDefault();}spacebarPressed=true;}};consthandleSpaceBarKeyup=(e: KeyboardEvent)=>{if(e.key===' '||e.code==='Space'){if(document.body===e.target||document.getElementById('scene')===e.target){e.stopPropagation();e.preventDefault();}spacebarPressed=false;}};document.removeEventListener('keydown',handleSpaceBarKeydown);document.addEventListener('keydown',handleSpaceBarKeydown);document.removeEventListener('keyup',handleSpaceBarKeyup);document.addEventListener('keyup',handleSpaceBarKeyup);constsceneElement=document.querySelector('.panzoom')asHTMLElement|null;if(sceneElement){const{default: panzoom}=awaitimport('panzoom');// And pass it to panzoomconstinstance=panzoom(sceneElementasHTMLElement,{beforeMouseDown: ()=>{constshouldIgnore=!spacebarPressed;returnshouldIgnore;},});}
Hi! I'm trying to set the space key as the one that triggers the panning functionality. It's a bigger key and i want my visitors to be able to select the text in the content that I'm writing.
I tried a lot of combinations, the one I thought would be the best would be this one:
panzoom(element, { beforeMouseDown: function(e) { const shouldIgnore = !(e.altKey || (e.code === 'Space')); return shouldIgnore; }, });
But it doesn't work either. What's the most appropriate way to do that with this library? Thanks
The text was updated successfully, but these errors were encountered: