Only use drag handler if any box isDragging

pull/2837/head
stweedo 2023-06-25 04:16:17 -05:00
parent be5fcdd185
commit b52220a070
3 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,4 @@
0.01: New App!
0.02: New config options such as step, meridian, short/long formats, custom prefix/suffix
0.03: Allows showing the month in short or long format by setting `"shortMonth"` to true or false
0.04: Improves touchscreen drag handling for background apps such as Pattern Launcher

View File

@ -4,6 +4,7 @@
* 1. Module dependencies and initial configurations
* ---------------------------------------------------------------
*/
let storage = require("Storage");
let locale = require("locale");
let widgets = require("widget_utils");
@ -30,6 +31,7 @@
* 2. Graphical and visual configurations
* ---------------------------------------------------------------
*/
let w = g.getWidth();
let h = g.getHeight();
let totalWidth, totalHeight;
@ -40,6 +42,7 @@
* 3. Touchscreen Handlers
* ---------------------------------------------------------------
*/
let touchHandler;
let dragHandler;
let movementDistance = 0;
@ -49,6 +52,7 @@
* 4. Font loading function
* ---------------------------------------------------------------
*/
let loadCustomFont = function() {
Graphics.prototype.setFontBrunoAce = function() {
// Actual height 23 (24 - 2)
@ -66,6 +70,7 @@
* 5. Initial settings of boxes and their positions
* ---------------------------------------------------------------
*/
for (let key in boxesConfig) {
if (key === 'bg' && boxesConfig[key].img) {
bgImage = storage.read(boxesConfig[key].img);
@ -167,6 +172,7 @@
* 7. String forming helper functions
* ---------------------------------------------------------------
*/
let isBool = function(val, defaultVal) {
return typeof val !== 'undefined' ? Boolean(val) : defaultVal;
};
@ -211,6 +217,7 @@
* 8. Main draw function
* ---------------------------------------------------------------
*/
let draw = (function() {
let updatePerMinute = true; // variable to track the state of time display
@ -272,6 +279,7 @@
* 9. Helper function for touch event
* ---------------------------------------------------------------
*/
let touchInText = function(e, boxItem, boxKey) {
calcBoxSize(boxItem);
const pos = calcBoxPos(boxKey);
@ -296,6 +304,7 @@
* 10. Setup function to configure event handlers
* ---------------------------------------------------------------
*/
let setup = function() {
// ------------------------------------
// Define the touchHandler function
@ -343,6 +352,8 @@
// Define the dragHandler function
// ------------------------------------
dragHandler = function(e) {
// Check if any box is being dragged
if (!Object.values(isDragging).some(Boolean)) return;
// Calculate the movement distance
movementDistance += Math.abs(e.dx) + Math.abs(e.dy);
// Check if the movement distance exceeds a threshold
@ -396,6 +407,7 @@
* 11. Main execution part
* ---------------------------------------------------------------
*/
Bangle.loadWidgets();
widgets.swipeOn();
modSetColor();

View File

@ -1,7 +1,7 @@
{
"id": "boxclk",
"name": "Box Clock",
"version": "0.03",
"version": "0.04",
"description": "A customizable clock with configurable text boxes that can be positioned to show your favorite background",
"icon": "app.png",
"screenshots": [