Merge lp:~abreu-alexandre/ubuntu-html5-theme/fix-toolbar-click-and-hide into lp:ubuntu-html5-theme

Proposed by Alexandre Abreu
Status: Merged
Merged at revision: 166
Proposed branch: lp:~abreu-alexandre/ubuntu-html5-theme/fix-toolbar-click-and-hide
Merge into: lp:ubuntu-html5-theme
Diff against target: 54 lines (+18/-5)
1 file modified
0.1/ambiance/js/toolbars.js (+18/-5)
To merge this branch: bzr merge lp:~abreu-alexandre/ubuntu-html5-theme/fix-toolbar-click-and-hide
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu HTML5 Theme Developers Pending
Review via email: mp+214222@code.launchpad.net

Commit message

Fix issues with the toolbar buttons:
- make sure that we dont preventDefault() in all cases (even when the user tries to click()),
- make sure that the user's intent seems like hiding/showing before doing so,

Description of the change

Fix issues with the toolbar buttons:
- make sure that we dont preventDefault() in all cases (even when the user tries to click()),
- make sure that the user's intent seems like hiding/showing before doing so,

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '0.1/ambiance/js/toolbars.js'
2--- 0.1/ambiance/js/toolbars.js 2014-02-13 17:20:57 +0000
3+++ 0.1/ambiance/js/toolbars.js 2014-04-04 12:22:09 +0000
4@@ -133,8 +133,6 @@
5 __onTouchStart: function (evt) {
6 this._touchDown = true;
7
8- evt.preventDefault();
9-
10 this.phase = this.PHASE_START;
11 var identifier = evt.identifier !== undefined ? evt.identifier : 0;
12
13@@ -159,8 +157,6 @@
14 return;
15
16 if (this.phase == this.PHASE_START) {
17- evt.preventDefault();
18-
19 var touchEvent =
20 this._touchInfoDelegate.translateTouchEvent(evt);
21
22@@ -170,8 +166,16 @@
23 f.end.x = touchEvent.touches[0].pageX;
24 f.end.y = touchEvent.touches[0].pageY;
25
26+ // Validate that the movement has a big enough amplitude
27+ // before considering it as a 'move'. The 0.4 is a value
28+ // that was setup after some experimentation on touch.
29+ var amplitude = this.__norm(f.start, f.end);
30+ if ((amplitude / this.toolbar.offsetHeight) < 0.4)
31+ return;
32+
33+ evt.preventDefault();
34+
35 direction = this.__calculateDirection(f.start, f.end);
36-
37 if (direction == "DOWN") {
38 this.hide();
39 }
40@@ -203,6 +207,15 @@
41 /**
42 * @private
43 */
44+ __norm: function (p1, p2) {
45+ var vx = p2.x - p1.x;
46+ var vy = p2.y - p1.y;
47+ return Math.sqrt(vx * vx + vy * vy);
48+ },
49+
50+ /**
51+ * @private
52+ */
53 __calculateDirection: function (startPoint, endPoint) {
54 var angle = this.__calculateAngle(startPoint, endPoint);
55

Subscribers

People subscribed via source and target branches