StageXL
StageXL copied to clipboard
iOS tap delay
I get the dreaded iOS tap delay, even when trying 3rd party libraries, such as FastClick.
I created a simple web app with stagehand
At least in that example, using MouseEvent.MOUSE_DOWN (or its touch equivalent) should do the trick.
And in more complex situations: animation on DOWN, 'submit' on UP. If you need dragging: start a listener to ENTER_FRAME after a certain delay on DOWN, and cancel the delay and listener on UP; also only 'submit' if the mousePos didn't change (apply a certain threshold).
But isn't that exactly what the library should be doing behind the scenes?
Hi guys. I don't know how or if the FastClick library is working, but the general advice is to register touch-events to get an immediate response on mobile devices. Please check out the StageOptions provided in the static StageXL class.
var isSupported = StageXL.environment.isTouchEventSupported;
StageXL.stageOptions.inputEventMode = InputEventMode.MouseOnly;
You can use the same event handlers for mouse and touch events, since all MouseEvents and TouchEvents extend the same base class called InputEvent. This should make it pretty easy to get optimal support for mouse and touch.
I tried to set it to InputEventMode.MouseOnly, but same result, still have the delay. I tried all the InputEventModes, actually.
Seems InputEventMode.MouseOnly is the default anyway.
yes this was just a copy-paste from an example, if you want to use touch input you have to set it to one of the touch modes. So you have to set the InputEventMode and also register to the touch events, this should give you instant feedback on user input.
You can also look at the example here: https://github.com/bp74/StageXL_Samples/blob/master/example/interactive/drag/index.dart
So, you get instant feedback on iOS if you set to InputEventMode.TouchOnly or InputEventMode.TouchAndMouse and use onTouchBegin. But I don't think this is a good solution, since every developer will have to implement something like @nilsdoehring suggested above for acceptable click behavior on iOS.
It'd be nice if devs could use MouseEvent.CLICK, not have iOS lag, and have it abstracted away for them, so they needn't worry about it.
Well we could do this, but the solution with a common event handler is not so much harder to implement. You could even use a helper function that adds both event handlers at the same time.
That's why I am in the process of creating the stagexl-commons library, which aims to solve, well, common stuff like this :-) It's not on pub yet, so you need to reference this github repo: https://github.com/blockforest/stagexl-commons/
For your use case, extend the Button class and override downAction and/or upAction. https://github.com/blockforest/stagexl-commons/blob/master/lib/src/view/interact/button/impl/button.dart
Disclaimer: stagexl-commons is not an official part of StageXL. Also, no animals have been harmed during its production.