~josharenson/unity8/qa_helpers

« back to all changes in this revision

Viewing changes to qml/Components/EdgeDragEvaluator.qml

  • Committer: Josh Arenson
  • Date: 2015-05-12 00:00:50 UTC
  • mfrom: (1757.1.15 unity8)
  • Revision ID: joshua.arenson@canonical.com-20150512000050-mt2cbx3a7p039zfw
Resolved merge conflicts

[ Albert Astals Cid ]
* Make runtests fake a test error if make fails
* Make the test more stable
* Use dbus-test-runner instead of dbus-launch
* DirectionalDragArea: improvements & API grooming (LP: #1417920)
* Fix EdgeDragEvaluator when a drag can happen both ways
  (Direction.Horizontal)
[ Josh Arenson ]
* Remove panelHeight property as it is unused.
[ Leo Arias ]
* Initial clean up of the autopilot tests set up. Removed the touch
  device from the test case. Moved the restart of unity to a fixture.
  Removed the unused DragMixin. Updated the setUpClass to use
  process_helpers. Removed the workaround for bug #1238417, already
  fixed. Use the toolkit helper to set the testability environment
  variable. Fixed the indicators base class that was restarting unity
  twice. (LP: #1238417, #1447206)
* Use the base class from the toolkit in autopilot tests.
[ Michael Zanetti ]
* emit application-stop when we're going down (LP: #1326513)
[ Michał Sawicz ]
* UNITY_SCOPES_LIST is no more
[ handsome_feng<445865575@qq.com> ]
* When click the favorite scope in Dash Manager , it just return to
  the corresponding scope page. (LP: #1447056)

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
        }
62
62
 
63
63
        velocity = calculate();
 
64
        minVelocity = __calculateMinimumVelocityForAutoCompletion();
64
65
 
65
 
        if (direction == Direction.Horizontal) {
66
 
            minVelocity = __calculateMinimumVelocityForAutoCompletion(Math.abs(deltaPos));
67
 
            return Math.abs(velocity) >= minVelocity;
 
66
        if (_dragDirectionIsPositive()) {
 
67
            return velocity >= minVelocity;
68
68
        } else {
69
 
            minVelocity = __calculateMinimumVelocityForAutoCompletion(deltaPos);
70
 
            if (Direction.isPositive(direction) && (velocity >= minVelocity)
71
 
                   || !Direction.isPositive(direction) && (velocity <= minVelocity)) {
72
 
                return true;
73
 
            } else {
74
 
                return false;
75
 
            }
 
69
            return velocity <= minVelocity;
76
70
        }
77
71
    }
78
72
 
81
75
    // speedThreshold in pixels per millisecond
82
76
    property real __speedThresholdMs: speedThreshold / 1000.0
83
77
 
84
 
    // Minimum velocity when a drag total distance is zero
85
 
    property real __v0: Direction.isPositive(direction) ? __speedThresholdMs : - __speedThresholdMs
86
 
 
87
 
    function __calculateMinimumVelocityForAutoCompletion(distance) {
88
 
        return __v0 - ((__speedThresholdMs / dragThreshold) * distance);
 
78
    function _dragDirectionIsPositive() {
 
79
        if (direction === Direction.Horizontal) {
 
80
            return (trackedPosition - __startPosition) > 0;
 
81
        } else {
 
82
            return Direction.isPositive(direction);
 
83
        }
 
84
    }
 
85
 
 
86
    function __calculateMinimumVelocityForAutoCompletion() {
 
87
        // Minimum velocity when a drag total distance is zero
 
88
        var v0 = _dragDirectionIsPositive() ? __speedThresholdMs : - __speedThresholdMs;
 
89
        var deltaPos = trackedPosition - __startPosition;
 
90
 
 
91
        return v0 - ((__speedThresholdMs / dragThreshold) * deltaPos);
89
92
    }
90
93
 
91
94
    function reset() {