[OpenLayers-Trac] Re: [OpenLayers] #3133: click handler should distinguish between pinches, clicks, and double-clicks

OpenLayers trac-20090302 at openlayers.org
Mon Mar 7 10:21:54 EST 2011


#3133: click handler should distinguish between pinches, clicks, and double-clicks
---------------------------+------------------------------------------------
 Reporter:  tschaub        |       Owner:  tschaub     
     Type:  bug            |      Status:  new         
 Priority:  minor          |   Milestone:  2.11 Release
Component:  Handler.Click  |     Version:  2.10        
 Keywords:  mobile         |       State:  Review      
---------------------------+------------------------------------------------

Comment(by tschaub):

 Basically, the click handler and the pinch handler do not play well
 together.  This patch is meant to make things better.

 Summary of changes:

  * tests/Control/TouchNavigation.html - Tests added to confirm that click
 handler options can be set via the control's options.  By default, the
 touch navigation control creates a click handler with a 2 pixel tolerance
 for clicks.

  * tests/Handler/Click.html - These changes confirm that the new
 dblclickTolerance property works as expected and that the existing
 pixelTolerance property is used.  The tests needed an overhaul to make it
 so assertions were not conditionally run.

  * lib/OpenLayers/Control/PinchZoom.js - The pinch zoom control needs to
 start tracking the current center on pinch start (in case there is no
 pinch move before done).  Then in the done callback, we only call
 setCenter if either the zoom or the center actually changed.

  * lib/OpenLayers/Control/TouchNavigation.js - Added support for passing
 options to the click handler.  By default, the click handler in the touch
 navigation control will have a non-zero pixel tolerance.  This allows
 sloppy fingers to click.

  * lib/OpenLayers/Handler/Click.js - The dblclickTolerance property is
 added to make it so the double-click callback is not called for clicks
 that are very far away from one another.  The rest of the event handling
 code is refactored to cleanly separate device event listeners from common
 handler methods (touch event listeners don't call mouse event listeners,
 instead both call common methods).  With this change, we can immediately
 unregister mouse listeners in a touch environment, preventing duplicate
 handling when touch and mouse events propagate.  In addition, the
 pixelTolerance property is now used to determine if a multi-touch event is
 a click.

  * lib/OpenLayers/Handler/Pinch.js - The pinch handler needs to prevent
 the default behavior of a touchstart (to avoid document scrolling), but it
 does not need to stop propagation to other listeners.  This allows the
 pinch handler and the click handler to work well together regardless of
 which is activated first.  Because the click handler now properly uses
 pixelTolerance and dblclickTolerance, we can safely let touch events be
 handled there even when they are part of a pinch.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3133#comment:7>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list