Select to view content in your preferred language

Disable zoom only when a valid hitTest target found

385
0
06-16-2021 03:54 AM
ChristopheS
New Contributor II

Hi all,

Is there a way to disable double click zoom, only when a hitTest target has been found ?

I have tried  many ways, as to clone event and then dispatch it in case no hitest is found, or use emit.

But no solution for instance ! Something like view.emit( "double-click", evtCopy ) does nothing.

e.g. :

 

view.on("double-click", function(evt)
{
	const opts = {
		include: [layer1, layer2]
	};
	//evt.stopPropagation();// Disable double-click zoom works but disables ALL cases
	view.hitTest(evt, opts).then(function(response)
	{
		if( response.results.length )// check if a feature is returned from one of the aimed layers
		{
			evt.stopPropagation();// This do not work as it is too late
			const graphic0 = response.results[0].graphic;
			processTarget(graphic0);
		}
		else
			evt.native.target.dispatchEvent( evt.native );// if not valid target, trigger regular dbl-click events anyway: not working
	});
});

 

 

 

 

Regards,

Chris

0 Kudos
0 Replies