Skip to content

Commit 413b33f

Browse files
author
Corwin Kerr
committed
Suggestions from review: emit events from Bangle and moving force_blur calls
1 parent e985056 commit 413b33f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

apps/widclkinfo/widget.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ if (!require("clock_info").loadCount) { // don't load if a clock_info was alread
6161
widget_utils.on("hidden", () => {
6262
console.log("hidden");
6363
clockInfoMenu.y = -24;
64-
clockInfoMenu.force_blur(); // needs to be here so it doesn't stay the focused color
6564
if (clockInfoMenu.focus) {
66-
//clockInfoMenu.force_blur();
65+
clockInfoMenu.force_blur();
6766
console.log("Forced blur bc hidden");
6867
}
6968
});

modules/widget_utils.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.hide = function() {
1111
w.area = "";
1212
if (w.x!=undefined) g.clearRect(w.x,w.y,w.x+w.width-1,w.y+23);
1313
}
14+
// TODO: do we need to emit event here too?
1415
};
1516

1617
/// Show any hidden widgets
@@ -134,11 +135,11 @@ exports.swipeOn = function(autohide) {
134135
if (dir>0 && exports.offset>=0) { // fully down
135136
stop = true;
136137
exports.offset = 0;
137-
exports.emit("shown");
138+
Bangle.emit("widgets-shown");
138139
} else if (dir<0 && exports.offset<-23) { // fully up
139140
stop = true;
140141
exports.offset = -24;
141-
exports.emit("hidden");
142+
Bangle.emit("widgets-hidden");
142143
}
143144
if (stop) {
144145
clearInterval(exports.animInterval);
@@ -160,8 +161,14 @@ exports.swipeOn = function(autohide) {
160161
anim(-4);
161162
}, exports.autohide);
162163
};
163-
if (ud>0 && exports.offset<0) anim(4, cb);
164-
if (ud<0 && exports.offset>-24) anim(-4);
164+
if (ud>0 && exports.offset<0) {
165+
Bangle.emit("widgets-start-show");
166+
anim(4, cb);
167+
}
168+
if (ud<0 && exports.offset>-24) {
169+
Bangle.emit("widgets-start-hide");
170+
anim(-4);
171+
}
165172
};
166173
Bangle.on("swipe", exports.swipeHandler);
167174
Bangle.drawWidgets();

0 commit comments

Comments
 (0)