~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/lib/OpenLayers/Control/DragPan.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
 
2
 * license.  See http://svn.openlayers.org/trunk/openlayers/license.txt for the
 
3
 * full text of the license. */
 
4
 
 
5
/**
 
6
 * @requires OpenLayers/Control.js
 
7
 * @requires OpenLayers/Handler/Drag.js
 
8
 */
 
9
 
 
10
/**
 
11
 * Class: OpenLayers.Control.DragPan
 
12
 * DragPan control.
 
13
 *
 
14
 * Inherits from:
 
15
 *  - <OpenLayers.Control>
 
16
 */
 
17
OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
 
18
 
 
19
    /** 
 
20
     * Property: type
 
21
     * {OpenLayers.Control.TYPES}
 
22
     */
 
23
    type: OpenLayers.Control.TYPE_TOOL,
 
24
    
 
25
    /**
 
26
     * Property: panned
 
27
     * {Boolean} The map moved.
 
28
     */
 
29
    panned: false,
 
30
    
 
31
    /**
 
32
     * Property: interval
 
33
     * {Integer} The number of milliseconds that should ellapse before
 
34
     *     panning the map again. Set this to increase dragging performance.
 
35
     *     Defaults to 25 milliseconds.
 
36
     */
 
37
    interval: 25, 
 
38
    
 
39
    /**
 
40
     * Method: draw
 
41
     * Creates a Drag handler, using <panMap> and
 
42
     * <panMapDone> as callbacks.
 
43
     */    
 
44
    draw: function() {
 
45
        this.handler = new OpenLayers.Handler.Drag(this, {
 
46
                "move": this.panMap,
 
47
                "done": this.panMapDone
 
48
            }, {
 
49
                interval: this.interval
 
50
            }
 
51
        );
 
52
    },
 
53
 
 
54
    /**
 
55
    * Method: panMap
 
56
    *
 
57
    * Parameters:
 
58
    * xy - {<OpenLayers.Pixel>} Pixel of the mouse position
 
59
    */
 
60
    panMap: function(xy) {
 
61
        this.panned = true;
 
62
        this.map.pan(
 
63
            this.handler.last.x - xy.x,
 
64
            this.handler.last.y - xy.y,
 
65
            {dragging: this.handler.dragging, animate: false}
 
66
        );
 
67
    },
 
68
    
 
69
    /**
 
70
     * Method: panMapDone
 
71
     * Finish the panning operation.  Only call setCenter (through <panMap>)
 
72
     *     if the map has actually been moved.
 
73
     *
 
74
     * Parameters:
 
75
     * xy - {<OpenLayers.Pixel>} Pixel of the mouse position
 
76
     */
 
77
    panMapDone: function(xy) {
 
78
        if(this.panned) {
 
79
            this.panMap(xy);
 
80
            this.panned = false;
 
81
        }
 
82
    },
 
83
 
 
84
    CLASS_NAME: "OpenLayers.Control.DragPan"
 
85
});