@@ -133,6 +133,7 @@ Item {
133133 jumpDetails .toRotation = ! isNaN (rotation) ? rotation : - 1 ;
134134 jumpDetails .position = 0.0 ;
135135 jumpDetails .handleMargins = handleMargins;
136+ kineticHandler .stopAll ();
136137 freeze (' jumping' );
137138 jumpDetails .enabled = true ;
138139 jumpDetails .position = 1.0 ;
@@ -220,6 +221,12 @@ Item {
220221 }
221222 }
222223
224+ KineticHandler {
225+ id: kineticHandler
226+ mapCanvas: mapArea
227+ mapCanvasWrapper: mapCanvasWrapper
228+ }
229+
223230 MapCanvasMap {
224231 id: mapCanvasWrapper
225232
@@ -279,6 +286,9 @@ Item {
279286 }
280287
281288 onPressedChanged: {
289+ if (pressed) {
290+ kineticHandler .stopAll ();
291+ }
282292 if (longPressActive)
283293 mapArea .longPressReleased (" stylus" );
284294 longPressActive = false ;
@@ -295,27 +305,38 @@ Item {
295305 dragThreshold: 5
296306
297307 property var oldPos
298- property real oldTranslationY
308+ property real oldTranslationY: 0
309+ property real activeScale: 1.0
299310
300311 property bool isZooming: false
301312 property bool isPanning: false
302313 property point zoomCenter
303314
304315 onActiveChanged: {
305316 if (active) {
317+ kineticHandler .stopAll ();
306318 if (mainTapHandler .doublePressed ) {
307319 oldTranslationY = 0 ;
320+ activeScale = 1.0 ;
308321 zoomCenter = centroid .position ;
309322 isZooming = true ;
323+ kineticHandler .resetZoomSamples ();
324+ kineticHandler .addZoomSample (1.0 );
310325 freeze (' zoom' );
311326 } else {
312327 oldPos = centroid .position ;
313328 isPanning = true ;
329+ kineticHandler .resetPanSamples ();
330+ kineticHandler .addPanSample (centroid .position .x , centroid .position .y );
314331 freeze (' pan' );
315332 }
316333 } else {
317- if (isZooming || isPanning) {
318- unfreeze (isZooming ? ' zoom' : ' pan' );
334+ if (isPanning) {
335+ kineticHandler .startPanInertia ();
336+ unfreeze (' pan' );
337+ } else if (isZooming) {
338+ kineticHandler .startZoomInertia (centroid .position );
339+ unfreeze (' zoom' );
319340 }
320341 isZooming = false ;
321342 isPanning = false ;
@@ -325,9 +346,12 @@ Item {
325346 onCentroidChanged: {
326347 if (active) {
327348 if (isZooming) {
349+ activeScale += (1 - Math .pow (0.8 , (translation .y - oldTranslationY) / 60 ));
350+ kineticHandler .addZoomSample (activeScale);
328351 mapCanvasWrapper .zoomByFactor (zoomCenter, Math .pow (0.8 , (translation .y - oldTranslationY) / 60 ));
329352 oldTranslationY = translation .y ;
330353 } else if (isPanning) {
354+ kineticHandler .addPanSample (centroid .position .x , centroid .position .y );
331355 mapCanvasWrapper .pan (centroid .position , oldPos);
332356 oldPos = centroid .position ;
333357 }
@@ -365,6 +389,9 @@ Item {
365389
366390 onPressedChanged: {
367391 if (pressed) {
392+ if (! pinchHandler .pinchReleasing ) {
393+ kineticHandler .stopAll ();
394+ }
368395 if (point .pressedButtons !== Qt .RightButton ) {
369396 if (timer .running ) {
370397 timer .stop ();
@@ -405,27 +432,40 @@ Item {
405432 dragThreshold: 5
406433
407434 property var oldPos
408- property real oldTranslationY
435+ property real oldTranslationY: 0.0
436+ property real activeScale: 1.0
409437
410438 property bool isZooming: false
411439 property bool isPanning: false
412440 property point zoomCenter
413441
414442 onActiveChanged: {
415443 if (active) {
444+ if (! pinchHandler .pinchReleasing ) {
445+ kineticHandler .stopAll ();
446+ }
416447 if (mainTapHandler .doublePressed ) {
417448 oldTranslationY = 0 ;
449+ activeScale = 1.0 ;
418450 zoomCenter = centroid .position ;
419451 isZooming = true ;
452+ kineticHandler .resetZoomSamples ();
453+ kineticHandler .addZoomSample (1.0 );
420454 freeze (' zoom' );
421455 } else {
422456 oldPos = centroid .position ;
423457 isPanning = true ;
458+ kineticHandler .resetPanSamples ();
459+ kineticHandler .addPanSample (centroid .position .x , centroid .position .y );
424460 freeze (' pan' );
425461 }
426462 } else {
427- if (isZooming || isPanning) {
428- unfreeze (isZooming ? ' zoom' : ' pan' );
463+ if (isPanning) {
464+ kineticHandler .startPanInertia ();
465+ unfreeze (' pan' );
466+ } else if (isZooming) {
467+ kineticHandler .startZoomInertia (centroid .position );
468+ unfreeze (' zoom' );
429469 }
430470 isZooming = false ;
431471 isPanning = false ;
@@ -435,9 +475,12 @@ Item {
435475 onCentroidChanged: {
436476 if (active) {
437477 if (isZooming) {
478+ activeScale += (1 - Math .pow (0.8 , (translation .y - oldTranslationY) / 60 ));
479+ kineticHandler .addZoomSample (activeScale);
438480 mapCanvasWrapper .zoomByFactor (zoomCenter, Math .pow (0.8 , (translation .y - oldTranslationY) / 60 ));
439481 oldTranslationY = translation .y ;
440482 } else if (isPanning) {
483+ kineticHandler .addPanSample (centroid .position .x , centroid .position .y );
441484 mapCanvasWrapper .pan (centroid .position , oldPos);
442485 oldPos = centroid .position ;
443486 }
@@ -568,23 +611,36 @@ Item {
568611
569612 property bool rotationActive: false
570613 property bool rotationTresholdReached: false
614+ property bool pinchReleasing: false
571615
572616 onActiveChanged: {
573617 if (active) {
618+ kineticHandler .stopAll ();
574619 freeze (' pinch' );
575620 oldScale = 1.0 ;
576621 oldRotation = 0.0 ;
577622 rotationTresholdReached = false ;
578623 oldPos = centroid .position ;
624+ kineticHandler .resetPanSamples ();
625+ kineticHandler .resetZoomSamples ();
626+ kineticHandler .addPanSample (centroid .position .x , centroid .position .y );
627+ kineticHandler .addZoomSample (1.0 );
579628 } else {
629+ pinchReleasing = true ;
630+ kineticHandler .startPanInertia ();
631+ kineticHandler .startZoomInertia (centroid .position );
580632 unfreeze (' pinch' );
633+ Qt .callLater (function () {
634+ pinchReleasing = false ;
635+ });
581636 }
582637 }
583638
584639 onCentroidChanged: {
585640 var oldPos1 = oldPos;
586641 oldPos = centroid .position ;
587642 if (active) {
643+ kineticHandler .addPanSample (centroid .position .x , centroid .position .y );
588644 mapCanvasWrapper .pan (centroid .position , oldPos1);
589645 }
590646 }
@@ -602,9 +658,12 @@ Item {
602658 }
603659
604660 onActiveScaleChanged: {
605- mapCanvasWrapper .zoomByFactor (pinchHandler .centroid .position , oldScale / pinchHandler .activeScale );
606- mapCanvasWrapper .pan (pinchHandler .centroid .position , oldPos);
607- oldScale = pinchHandler .activeScale ;
661+ if (active) {
662+ kineticHandler .addZoomSample (pinchHandler .activeScale );
663+ mapCanvasWrapper .zoomByFactor (pinchHandler .centroid .position , oldScale / pinchHandler .activeScale );
664+ mapCanvasWrapper .pan (pinchHandler .centroid .position , oldPos);
665+ oldScale = pinchHandler .activeScale ;
666+ }
608667 }
609668 }
610669
0 commit comments