Only use drag handler if any box isDragging
parent
be5fcdd185
commit
b52220a070
|
|
@ -1,3 +1,4 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: New config options such as step, meridian, short/long formats, custom prefix/suffix
|
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.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
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
* 1. Module dependencies and initial configurations
|
* 1. Module dependencies and initial configurations
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let storage = require("Storage");
|
let storage = require("Storage");
|
||||||
let locale = require("locale");
|
let locale = require("locale");
|
||||||
let widgets = require("widget_utils");
|
let widgets = require("widget_utils");
|
||||||
|
|
@ -30,6 +31,7 @@
|
||||||
* 2. Graphical and visual configurations
|
* 2. Graphical and visual configurations
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let w = g.getWidth();
|
let w = g.getWidth();
|
||||||
let h = g.getHeight();
|
let h = g.getHeight();
|
||||||
let totalWidth, totalHeight;
|
let totalWidth, totalHeight;
|
||||||
|
|
@ -40,6 +42,7 @@
|
||||||
* 3. Touchscreen Handlers
|
* 3. Touchscreen Handlers
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let touchHandler;
|
let touchHandler;
|
||||||
let dragHandler;
|
let dragHandler;
|
||||||
let movementDistance = 0;
|
let movementDistance = 0;
|
||||||
|
|
@ -49,6 +52,7 @@
|
||||||
* 4. Font loading function
|
* 4. Font loading function
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let loadCustomFont = function() {
|
let loadCustomFont = function() {
|
||||||
Graphics.prototype.setFontBrunoAce = function() {
|
Graphics.prototype.setFontBrunoAce = function() {
|
||||||
// Actual height 23 (24 - 2)
|
// Actual height 23 (24 - 2)
|
||||||
|
|
@ -66,6 +70,7 @@
|
||||||
* 5. Initial settings of boxes and their positions
|
* 5. Initial settings of boxes and their positions
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (let key in boxesConfig) {
|
for (let key in boxesConfig) {
|
||||||
if (key === 'bg' && boxesConfig[key].img) {
|
if (key === 'bg' && boxesConfig[key].img) {
|
||||||
bgImage = storage.read(boxesConfig[key].img);
|
bgImage = storage.read(boxesConfig[key].img);
|
||||||
|
|
@ -167,6 +172,7 @@
|
||||||
* 7. String forming helper functions
|
* 7. String forming helper functions
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let isBool = function(val, defaultVal) {
|
let isBool = function(val, defaultVal) {
|
||||||
return typeof val !== 'undefined' ? Boolean(val) : defaultVal;
|
return typeof val !== 'undefined' ? Boolean(val) : defaultVal;
|
||||||
};
|
};
|
||||||
|
|
@ -211,6 +217,7 @@
|
||||||
* 8. Main draw function
|
* 8. Main draw function
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let draw = (function() {
|
let draw = (function() {
|
||||||
let updatePerMinute = true; // variable to track the state of time display
|
let updatePerMinute = true; // variable to track the state of time display
|
||||||
|
|
||||||
|
|
@ -272,6 +279,7 @@
|
||||||
* 9. Helper function for touch event
|
* 9. Helper function for touch event
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let touchInText = function(e, boxItem, boxKey) {
|
let touchInText = function(e, boxItem, boxKey) {
|
||||||
calcBoxSize(boxItem);
|
calcBoxSize(boxItem);
|
||||||
const pos = calcBoxPos(boxKey);
|
const pos = calcBoxPos(boxKey);
|
||||||
|
|
@ -296,6 +304,7 @@
|
||||||
* 10. Setup function to configure event handlers
|
* 10. Setup function to configure event handlers
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let setup = function() {
|
let setup = function() {
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
// Define the touchHandler function
|
// Define the touchHandler function
|
||||||
|
|
@ -343,6 +352,8 @@
|
||||||
// Define the dragHandler function
|
// Define the dragHandler function
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
dragHandler = function(e) {
|
dragHandler = function(e) {
|
||||||
|
// Check if any box is being dragged
|
||||||
|
if (!Object.values(isDragging).some(Boolean)) return;
|
||||||
// Calculate the movement distance
|
// Calculate the movement distance
|
||||||
movementDistance += Math.abs(e.dx) + Math.abs(e.dy);
|
movementDistance += Math.abs(e.dx) + Math.abs(e.dy);
|
||||||
// Check if the movement distance exceeds a threshold
|
// Check if the movement distance exceeds a threshold
|
||||||
|
|
@ -396,6 +407,7 @@
|
||||||
* 11. Main execution part
|
* 11. Main execution part
|
||||||
* ---------------------------------------------------------------
|
* ---------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
widgets.swipeOn();
|
widgets.swipeOn();
|
||||||
modSetColor();
|
modSetColor();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "boxclk",
|
"id": "boxclk",
|
||||||
"name": "Box Clock",
|
"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",
|
"description": "A customizable clock with configurable text boxes that can be positioned to show your favorite background",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue