1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  | /** 
 |   * ext-panning.js 
 |   * 
 |   * @license MIT 
 |   * 
 |   * @copyright 2013 Luis Aguirre 
 |   * 
 |   */ 
 |  /* 
 |    This is a very basic SVG-Edit extension to let tablet/mobile devices pan without problem 
 |  */ 
 |  export default { 
 |    name: 'panning', 
 |    async init ({importLocale}) { 
 |      const strings = await importLocale(); 
 |      const svgEditor = this; 
 |      const svgCanvas = svgEditor.canvas; 
 |      const buttons = [{ 
 |        id: 'ext-panning', 
 |        icon: svgEditor.curConfig.extIconsPath + 'panning.png', 
 |        type: 'mode', 
 |        events: { 
 |          click () { 
 |            svgCanvas.setMode('ext-panning'); 
 |          } 
 |        } 
 |      }]; 
 |      return { 
 |        name: strings.name, 
 |        svgicons: svgEditor.curConfig.extIconsPath + 'ext-panning.xml', 
 |        buttons: strings.buttons.map((button, i) => { 
 |          return Object.assign(buttons[i], button); 
 |        }), 
 |        mouseDown () { 
 |          if (svgCanvas.getMode() === 'ext-panning') { 
 |            svgEditor.setPanning(true); 
 |            return {started: true}; 
 |          } 
 |        }, 
 |        mouseUp () { 
 |          if (svgCanvas.getMode() === 'ext-panning') { 
 |            svgEditor.setPanning(false); 
 |            return { 
 |              keep: false, 
 |              element: null 
 |            }; 
 |          } 
 |        } 
 |      }; 
 |    } 
 |  }; 
 |  
  |