Stop mouse wheel zoom in iframe

I want to display my Wick animations in an iframe.

A big problem is that if you accidentally use the mouse wheel when you’re over the iframe then you zoom in and can’t zoom out. This happens about 90% of the time.

CTRL + scroll doesn’t make any difference

e.g.

https://sites.google.com/view/teaching-energy/energy-spreading

(It takes a few seconds to load the simulation)

Any thoughts about what to do about this?

Thanks

Hi @novelPhenomena,

did you try to capture and disable the standard events?
Like this:

?
(Just asking - if you did, I don’t have to try it :-) )

regards,

Paul

Thanks, Paul.

That’s good advice.

Let me have a play around and see if I can make it work.

Julian

I have had the same problem:

This seems to happen when scrolling.
Is this the same scrolling problem u have?

Yup - that’s the one!

I wonder if someone at Wick could pick this up, because it’s a real headache for me at the moment.

You don’t seem to be able to capture mouse events in an iframe. e.g. this doesn’t work

<script>
	const frameObj = document.getElementById('simFrame');

	frameObj.contentDocument.addEventListener('wheel', function(event) {
		console.log(event);
	}, false);

</script>

And you can’t seem to capture the wheel even in the actual Wick document, so this doesn’t work either

window.document.addEventListener('wheel', function(event) {
  	//console.log(event);
  	event.preventDefault();
  	event.stopPropagation();
}, {passive:false});

window.document.body.addEventListener('wheel', function(event) {
  	//console.log(event);
  	event.preventDefault();
  	event.stopPropagation();
}, {passive:false});

document.addEventListener('wheel', function(event) {
  	//console.log(event);
  	event.preventDefault();
  	event.stopPropagation();
}, {passive:false});

because I still get this error

VM60:13 [Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312

for one thing, remove the <.script> and the <./script> because it’s only used for embedding js into html. other than that i can’t really help you. sorry :frowning:

Yes, of course. I didn’t show the HTML. :smile:

Hey @novelPhenomena, this is a problem I thought we had fixed previously. Will take a look!

Turns out this was a pretty simple bug (I think…). I’ve gone ahead and pushed a fix to the test branch on test.wickeditor.com. @novelPhenomena and @Hamzah_Al_Ani , let me know if this works for you.