Closed Whomiga closed 5 years ago
Not sure but there may be a problem with IITC with relation to the resolution/position and such for the DeX mode as I've found selecting the portals can be difficult under DeX, even for info.
What do I need to test this?
https://www.samsung.com/us/business/solutions/samsung-dex/
Just discovered it doesn't appear to be a DeX problem, it appears to be a mouse problem as I see the same problem as below using a mouse connected to my Note9, with no DeX connected.
It also doesn't matter if being done in Desktop or Phone mode
I've noticed that drawtools doesn't detect a mousepress (just selects the location on the map as if drawtools is not active) during draw polyline or draw polygon unless a drag is made in the location that a vertex is wanted. After the drag, the mouse pointer becomes a cross hair and a mousepress properly makes a vertex if the crosshair is not moved before mousepress ("refresh map movestart" is seen in debug console)
I've found that the Draw-Tools and all other operations of IITC Mobile work as designed when using DeX with the phone as a touchpad.
I confirm issue with mouse in IITCm. And official Leaflet.draw samples (e.g. https://leaflet.github.io/Leaflet.draw/docs/examples/full.html) does not have such problems.
I want to mention that there is another thing, which works great in leaflet.draw sample, but fails in iitc: it's a Circle (that's why we've disabled it in mobile mode).
- It also can be some WebView-related issue.
It is not:
So the problem is somewhere in iitc code.
This sample contain essentially the same code as above, but doesn't work:
So the problem is outside of draw-tools plugin code.
It's not oms
, it's not taphold
.
Also I removed from code all event listeners attached by .on(..)
and .click(...)
, and it not helped.
But if I create new map (after current map.remove()
), then in new map all is right.
Do you have a fork in which you have made your changes to be tested and/or examined?
Use code from details above. As for oms, taphold, and numerous event listeners, then I didn't keep that quick-and-dirty patch, but it shouldn't be hard to repeat it yourself.
BTW, I tend to think that another issue can be indirectly related: on mobile it's impossible to create circle and rectangle. I'm going to try to debug this, as it is reproduceable even on desktop (mobile mode in Chrome)
So I've found the bug source.
For correct work we must load Leaflet.draw before map initialization.
It can be fixed in upstream: https://github.com/Leaflet/Leaflet.draw/issues/923
But (as long as we know what's happening) it's also easy to fix the issue in our code.
I think I fully updated my fork with your changes, but the circle icon still isn't showing up in the mobile version (shows on desktop) - am I missing something on updating scripts in the APK or something? Mouse works great though, nice work.
Note: Shouldn't the use of a mouse be Click, then see a running length and dashed line till the next click, etc? - that is how it operates on the normal desktop version.
am I missing something on updating
Perhaps you've missed smartphone.css
am I missing something on updating
Perhaps you've missed
smartphone.css
Changed on my copy here, not sure if the APK is using it but I did the build.py local, etc...
After last commit we have issue with polyline https://github.com/Leaflet/Leaflet.draw/issues/789.
And the worst thing is that Leaflet.draw seems unmaintained.
I really doubt that we should include the fix into release, as it brings more problems than it solves.
Leaflet.draw
is buggy, and I do not feel that we are able to fix all cases.
BTW, I tend to think that current draw-tools
is also not convenient for most of our use cases, and we should look for alternatives (related: #144).
@Whomiga You still can use 'fixed' plugin as external. Or you can develop sort of smart behavior: activating DeX could affect TouchExtend handler.
P.S.
activating DeX
Perhaps better would be to detect if current pointer is mouse (it should be possible, I hope).
it brings more problems than it solves
I can try some compromise, like dynamically enable TouchExtend handler for Circle drawing only: #175
And would be happy to include fix, if you find it:
detect if current pointer is mouse
Changed on my copy here, not sure if the APK is using it but I did the build.py local, etc...
Make sure that you've updated total-conversion-build.user.js
too.
Note: Shouldn't the use of a mouse be Click, then see a running length and dashed line till the next click, etc?
Report this to upstream.
@Whomiga
detect if current pointer is mouse
Good news, I've got an idea: use ':hover' selector to check if we have active mouse pointer. I am not sure how reliable it is, so please check it in all configurations (incl. plain desktop).
I also have other ideas (in case if this one fails), so I keep some sources here:
@johnd0e
Good news, I've got an idea: use ':hover' selector to check if we have active mouse pointer.
It isn't correct, because ':hover' is initiated in most mobile browsers on each tap by some element. So you tap a button, for example, it activates ':hover', and it stays ':hover'-ed, as if you used a mouse to click and stayed hovered on it after the click.
@1valdis Too bad.. May be you have another idea?
@johnd0e There's a CSS media rule just for that: (pointer: fine). Unfortunately its browser support might be too poor to use with IITC. You may still check it out and use it only if it's supported. There's also solution which uses jQuery.
Unfortunately jQuery solution does not allow to make test immediately (only after click). And user can attach/detach mouse in any moment, so we need to test it dynamically.
There's a CSS media rule just for that: (pointer: fine).
May be it could be used, but also not in strait-forward way(
@johnd0e
May be it could be used, but also not in strait-forward way(
if (matchMedia('(pointer:fine)').matches) {
// Device has a mouse
}
(copied from answer on the same SO question) What's more straightforward? :)
What's more straightforward? :)
You are right, it is.
Unfortunately even with mouse attached I get false
.
But...
I succeed in using another media query: matchMedia('(hover:hover)')
Thank you!
I succeed in using another media query:
matchMedia('(hover:hover)')
This media query works the same way: matchMedia('(any-pointer:fine)')
Unfortunately both methods are only able to detect if mouse is attached. But none of them can detect if mouse is currently active.
It's obvious that browser itself has this info (we see pointer icon only when mouse is active)
I believe you should change your way of telling if the mouse is used from simple CSS media matching to events, if you want more control. Specifically, you can use pointer events instead of mouse or touch ones, and use their pointerType property. Their browser support though... leaves much to be desired, but I still recommend to check them out.
I believe you should change your way of telling if the mouse is used from simple CSS media matching to events, if you want more control.
Well, you are right. And it's rather easy.
But still it increases the whole complexity of this part of code.
And as this part is not more than a workaround over Leaflet.draw
bugs, I just try to keep it as simple as possible.
May be we should drop this hack, as I also have some progress from the opposite side: https://github.com/Leaflet/Leaflet.draw/pull/926
(Need more testing in different configurations..)
Works just fine on same phone in regular phone mode