Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: sky/framework/debug/shake-to-reload.sky

Issue 963303004: Implement shake-to-reload (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/examples/touch-demo.sky ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <script>
2 import '/sky/framework/shell.dart' as shell;
3 import 'dart:sky';
4 import 'package:sky/services/sensors/sensors.mojom.dart';
5
6 // TODO(abarth): We should factor this out into a kinemetics library.
eseidel 2015/02/27 23:29:53 kinematics
7 class _ShakeDetector extends SensorListener {
8 _ShakeDetector() {
9 SensorServiceProxy sensorService = new SensorServiceProxy.unbound();
10 shell.requestService(sensorService);
11
12 _stub = new SensorListenerStub.unbound()
13 ..delegate = this;
14 sensorService.ptr.addListener(SensorType_ACCELEROMETER, _stub);
15 _stub.listen();
16 }
17
18 void onAccuracyChanged(int accuracy) {
19 }
20
21 void onSensorChanged(SensorData data) {
22 double value = data.values[0] + data.values[1] + data.values[2];
23 if (isShaking && value < 15.0)
24 didCompleteShake();
25 else if (value > 40.0)
26 isShaking = true;
27 }
28
29 void didCompleteShake() {
30 window.location.assign(document.URL);
31 _stub.close();
32 }
33
34 bool isShaking = false;
35 SensorListenerStub _stub;
36 }
37
38 _ShakeDetector _detector;
39
40 void _init(_) {
41 _detector = new _ShakeDetector();
42 }
43 </script>
OLDNEW
« no previous file with comments | « sky/examples/touch-demo.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698