Completed
Last Updated: 05 Aug 2024 13:31 by ADMIN
Release 6.1.0
Plamen
Created on: 05 Sep 2023 06:49
Category: Map
Type: Bug Report
7
Unify the zoom action behavior when using the plus button and mouse wheel
The amount of clicks on the + button and the amount of mouse wheel scrolls is different if you refresh the Map component. 
4 comments
Michal
Posted on: 23 Jun 2024 17:48

hotfix  if you have ONLY ONE map at page.
- "ugly!!", but at least something:

<script>
var xlisteners = [];
//var gmapref = document.querySelector(".k-map") !! null
var f = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function (type, fn, capture) {
//this.f = f;
if (type == "wheel" && this.className.includes("k-map")) {
if (xlisteners.length > 0) { /*alert('skip...' + xlisteners.length);*/ return; }//DO NOTHING
this.f = f;
xlisteners.push(fn);//for later cleanup use...
this.f(type, fn, capture);
//alert('added...' + xlisteners.length);
}
else {
this.f = f;
this.f(type, fn, capture);
}

}

//jf you want it call from code like: await JS.InvokeVoidAsync("mcleanup", "abcdefg");

function mcleanup(mid) {
if (xlisteners.length > 1) {
var element = document.querySelector(".k-map");
for (let i = 1; i < xlisteners.length; i++) {
console.log(i, xlisteners[i]);
element.removeEventListener("wheel", xlisteners[i], { passive: true });
}
//xlisteners.forEach((it) => { element.removeEventListener("wheel", it, { passive: true }); console.log(it); });
xlisteners.splice(1);
alert('removed...');
}
}

</script>

Michal
Posted on: 16 Jun 2024 19:32

info for previous post:

- "hotfix" means, how to safely remove event listener "wheel", which is randomly multiplicating(maybe its caused by Map.Refresh() method? ). There should be only ONE listener.

Example of wrong 5 event listeners assigned to map and every of them do the scrool. So you get scrolled 5x per mouse wheel up/down:

if i delete it in browser object inspector, and leave only "one", everything is ok.

Some kind of "cleaner"(js call from code) will help, before full fix will be available.

 

Michal
Posted on: 16 Jun 2024 19:14

Hi,

 is there some temporary "external hotfix"?

- like: disabling mouse wheel zoom at JS level. Just mouse wheel, no others variants.

Plamen
Posted on: 05 Sep 2023 07:19

On every refresh, the zoom step of the mouse wheel increases. If the component is refreshed several times, the mouse wheel zooming and the +/- buttons from the keyboard become very confusing. They zoom in and out to the maximum/minimum zoom level. The MapControlsZoom component works properly.

If the map is used in application that intends to dynamically show different items on the map, the zooming quickly becomes a problem.