Merge lp:~joergberroth/unav/fix_map_longclick_behaviour into lp:unav

Proposed by JkB
Status: Merged
Merged at revision: 58
Proposed branch: lp:~joergberroth/unav/fix_map_longclick_behaviour
Merge into: lp:unav
Prerequisite: lp:~costales/unav/0.59-more-minor-improvements
Diff against target: 93 lines (+30/-31)
2 files modified
nav/index.html (+28/-30)
qml/PoiListPage.qml (+2/-1)
To merge this branch: bzr merge lp:~joergberroth/unav/fix_map_longclick_behaviour
Reviewer Review Type Date Requested Status
costales Approve
Nekhelesh Ramananthan testing Approve
Review via email: mp+292718@code.launchpad.net

Commit message

* small design fix for PoiListPage Button

*improved map long-click behavior to make it react as one would expect

Description of the change

* small design fix for PoiListPage Button

*improved map long-click behavior to make it react as one would expect

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Worked nicely! Nice work Joerg! So with release we have pinch-zoom, and long-press fixed as well. Great job guys!

@marcos, please do a code review. thnx

review: Approve (testing)
58. By JkB

*set longpress to 300ms

59. By JkB

*merge with trunk

60. By JkB

*merge costales fixes

Revision history for this message
costales (costales) wrote :

So awesome hack! Thanks Joerg!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nav/index.html'
2--- nav/index.html 2016-04-22 17:32:31 +0000
3+++ nav/index.html 2016-04-24 15:41:24 +0000
4@@ -419,45 +419,43 @@
5 // Map events
6 // Clicks
7 var longpress = false;
8- map.on('singleclick', function(evt) {
9- if (longpress) {
10+ var longpressTimer;
11+ var pointerIsDown = false;
12+ map.on('pointerdown', function(evt) {
13+ longpress = false;
14+ !pointerIsDown ? longpressTimer = window.setTimeout( function(){
15+ longpress = true;
16 var coord = ol.proj.transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326');
17+
18 while (coord[0] > 180) // Fix bug ol3 #4522
19 coord[0] = coord[0] - 360;
20 while (coord[0] < -180)
21 coord[0] = coord[0] + 360;
22-
23+
24 ui.markers_POI_set([{title: '', lat: coord[1], lng: coord[0]}]);
25-
26+
27 window.location = 'http://clicked_on_map?nofollow/' + coord[1] + '/' + coord[0] + '/none/none/none/none'; // Show popup
28- }
29- else {
30- window.location = 'http://hide_popup?';
31- }
32- });
33-
34- var startTime, endTime;
35- $("#map").on('touchstart', function () {
36- startTime = new Date().getTime();
37- });
38- $("#map").on('touchend', function () {
39- endTime = new Date().getTime();
40- longpress = (endTime - startTime < 225) ? false : true;
41- });
42-
43- /** TESTING BEGIN
44- $("#map").on('mousedown', function () {
45- startTime = new Date().getTime();
46- });
47- $("#map").on('mouseup', function () {
48- endTime = new Date().getTime();
49- longpress = (endTime - startTime < 225) ? false : true;
50- });
51- TESTING END **/
52-
53+ },
54+ 300 /**longpress time constant **/ ) : undefined;
55+ pointerIsDown=true;
56+ });
57+
58+ map.on('pointermove', function(evt) {
59+ window.clearTimeout(longpressTimer);
60+ });
61+
62+ map.on('singleclick', function(evt) {
63+ !longpress ? window.location = 'http://hide_popup?' : undefined;
64+ });
65+
66+ map.on('pointerup', function () {
67+ window.clearTimeout(longpressTimer);
68+ pointerIsDown=false;
69+ });
70+
71 // Drag
72 map.on('pointerdrag', function(evt) {
73- ui.set_zoom_unav(false); // Pinch zoom = custom zoom too
74+ window.clearTimeout(longpressTimer);
75
76 if (id_gps != 0 && ui.get_center_onpos()) { // Unfocus center if GPS ON
77 ui.set_center_onpos(false);
78
79=== modified file 'qml/PoiListPage.qml'
80--- qml/PoiListPage.qml 2016-04-20 17:36:04 +0000
81+++ qml/PoiListPage.qml 2016-04-24 15:41:24 +0000
82@@ -123,9 +123,10 @@
83 id: distButton
84 visible: false
85 z: 500
86+ width: parent.width*5/8
87 anchors {
88 top: distSlider.bottom
89- topMargin: units.gu (1)
90+ topMargin: units.gu (3)
91 horizontalCenter: parent.horizontalCenter
92 }
93 iconName: "reload"

Subscribers

People subscribed via source and target branches