pointercancel event emits by an unknown reason
Reported by
lcllao1...@gmail.com,
Jan 22 2017
|
|||||
Issue descriptionSteps to reproduce the problem: 1. Use a phone which supports PointerEvent(like Android 7 HUA-WEI,would enable PointerEvent by default) to open my test case,also you can use desktop Chrome Developer Tools to simulate a phone device and open the PointerEvent support in chrome://flags/ . The demo page would listen pouchstart,touchmove,touchcancel,touchend,pointerdown,pointermove,pointercancel,pointerup in the red area,and the scroll event in the window. 2. touch the red area,then you can see the log in console like: >pointerdown >touchstart 3. move your finger to the bottom side(not to the top,won't trigger scroll),then the console would print like: >pointermove >touchmove >pointercancel >touchmove >touchmove >... What is the expected behavior? pointercancel won't emit while the user not doing the operation like scroll,zoom,refresh What went wrong? Why the pointercancel event emitted in that case? https://developers.google.com/web/updates/2016/10/pointer-events tells us: pointercancel:Something has happened that means it’s unlikely the pointer will emit any more events. This means you should cancel any in-progress actions and go back to a neutral input state. .... In touch-enabled browsers, certain gestures are used to make the page scroll, zoom, or refresh. In the case of touch events, you will still receive events while these default actions are taking place – for instance, touchmove will still be fired while the user is scrolling. With pointer events, whenever a default action like scroll or zoom is triggered, you’ll get a pointercancel event, to let you know that the browser has taken control of the pointer. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 55.0.2883.87 Channel: stable OS Version: 7 Flash Version:
,
Jan 23 2017
,
Jan 23 2017
The page is working correctly and the guidance is correct. Perhaps you are misunderstanding the guidance. A pointercancel is issued once the browser takes over the event stream and starts doing its user agent actions like scroll and zoom. What you are seeing is the drag down causes the scroll which then the browser starts scrolling and then issues a pointercancel. Likewise you will see touchmove events become uncancelable after that.
,
Jan 23 2017
,
Jan 25 2017
Thank you for answering my question. I also listent the scroll event on window. When I pointed my finger down an move it to the top side ,it will starts scrolling,then issues a pointercancel event is right. But I move to the opposide direction,it won't starts scrolling because it is on the top now. We can also set the height of the div to 200px,then the browser won't starts scrolling in any direction.
,
Jan 25 2017
The pointercancel is generated when the user agent decides to scroll even if the scrolling has no effect (as you moving in the top direction) it is still generated. ie; The sequence is that the user agent decides the user is doing a scrolling gesture so it will generate a scroll event and issue a pointer cancel. The fact that the scroll gesture didn't have any effect doesn't cause the pointercancel not to be issued. Understand?
,
Jan 25 2017
OK,I got it. According to `https://developers.google.com/web/updates/2016/10/pointer-events`, pointer events is made for unifing the event models such as mouse,pen,touch. Under the pointer event model,mobile platform,when user put their finger on the screen and start moving,the browser just issue one pointercancel event and one pointermove event. How should we use it on the mobile platform for making a drag plugin(drag any items the user pointed at to the other place on the page),a iScroll like plugin(custom scroll,in iOS and Android,scroll event won't issue immediately when the browser starts scrolling)? In the old time we can use the touchstart,touchmove,touchend events. Should the pointer event model fully taking the place of the touch event model?
,
Jan 25 2017
You can use "touch-action: none" which would prevent the default user action for the custom scroll. Although I'm not sure why you would want to cause main thread scrolling because threaded scrolling is much more responsive to the user. A draggable plugin you want a touch-action none and probably use pointer capture. For example see: https://patrickhlauke.github.io/touch/tests/pointercapture.html
,
Jan 25 2017
Thanks ^_^ I have a list with thousands of items and fast word index(a-z) on the page,just like the contact list in our phone. In the App WebView,the performance is much lower than original browser, and it causes the problem like app crash(Memory), low FPS(script, rendering, Memory), screen flashing (set scrollTop to jump from word 'a' to 'd'). I have to find a way to enhance performance such as reducing number of DOM elements by modifing the list items while the view is scrolling. In fact, the scroll event won't fire until the browser stop scrolling.So I use touch event to simulate it,just like iScroll-infinite (http://lab.cubiq.org/iscroll5/demos/infinite/). In that demo,they use : "document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false)", to prevent scrolling. Although there are many ways to prevent the pointercancel event,I still having a doute that developers must write extra code to let pointer event can replace touch event or mouse event. Is there any way I can figure out why the browser issues a pointercancel event even if the scrolling has no effect? I can't find any clew in "https://w3c.github.io/pointerevents/#the-pointercancel-event". Thanks for your time again ^_^ |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by tkent@chromium.org
, Jan 22 2017