x4js 1.4.16 → 1.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application.d.ts +3 -1
- package/lib/application.js +16 -14
- package/lib/router.js +1 -1
- package/package.json +1 -1
- package/src/application.ts +19 -17
- package/src/router.ts +1 -1
package/lib/application.d.ts
CHANGED
|
@@ -75,6 +75,8 @@ export declare class Application<P extends ApplicationProps = ApplicationProps,
|
|
|
75
75
|
private m_app_uid;
|
|
76
76
|
private m_local_storage;
|
|
77
77
|
private m_user_data;
|
|
78
|
+
private m_touch_time;
|
|
79
|
+
private m_touch_count;
|
|
78
80
|
constructor(props: P);
|
|
79
81
|
ApplicationCreated(): void;
|
|
80
82
|
get app_name(): string;
|
|
@@ -96,6 +98,6 @@ export declare class Application<P extends ApplicationProps = ApplicationProps,
|
|
|
96
98
|
setTitle(title: string): void;
|
|
97
99
|
disableZoomWheel(): void;
|
|
98
100
|
enterModal(enter: boolean): void;
|
|
99
|
-
|
|
101
|
+
enableTouchDblClick(): void;
|
|
100
102
|
}
|
|
101
103
|
export {};
|
package/lib/application.js
CHANGED
|
@@ -33,6 +33,7 @@ const base_component_1 = require("./base_component");
|
|
|
33
33
|
const component_1 = require("./component");
|
|
34
34
|
const settings_1 = require("./settings");
|
|
35
35
|
const tools_1 = require("./tools");
|
|
36
|
+
const _x4_touch_time = Symbol();
|
|
36
37
|
/**
|
|
37
38
|
* Represents an x4 application, which is typically a single page app.
|
|
38
39
|
* You should inherit Application to define yours.
|
|
@@ -66,6 +67,8 @@ class Application extends base_component_1.BaseComponent {
|
|
|
66
67
|
m_app_uid;
|
|
67
68
|
m_local_storage;
|
|
68
69
|
m_user_data;
|
|
70
|
+
m_touch_time;
|
|
71
|
+
m_touch_count;
|
|
69
72
|
constructor(props) {
|
|
70
73
|
console.assert(Application.self === null, 'application is a singleton');
|
|
71
74
|
super(props);
|
|
@@ -75,6 +78,8 @@ class Application extends base_component_1.BaseComponent {
|
|
|
75
78
|
let settings_name = `${this.m_app_name}.${this.m_app_version}.settings`;
|
|
76
79
|
this.m_local_storage = new settings_1.Settings(settings_name);
|
|
77
80
|
this.m_user_data = {};
|
|
81
|
+
this.m_touch_time = 0;
|
|
82
|
+
this.m_touch_count = 0;
|
|
78
83
|
Application.self = this;
|
|
79
84
|
if ('onload' in globalThis) {
|
|
80
85
|
globalThis.addEventListener('load', () => {
|
|
@@ -146,29 +151,26 @@ class Application extends base_component_1.BaseComponent {
|
|
|
146
151
|
}
|
|
147
152
|
enterModal(enter) {
|
|
148
153
|
}
|
|
149
|
-
|
|
154
|
+
enableTouchDblClick() {
|
|
150
155
|
document.addEventListener('touchstart', (ev) => {
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
me.__touch_cnt = 1;
|
|
156
|
+
let now = Date.now();
|
|
157
|
+
if ((now - this.m_touch_time) > 700) {
|
|
158
|
+
this.m_touch_count = 1;
|
|
155
159
|
}
|
|
156
160
|
else {
|
|
157
|
-
|
|
161
|
+
this.m_touch_count++;
|
|
158
162
|
}
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
type: "dblclick",
|
|
164
|
-
};
|
|
163
|
+
this.m_touch_time = now;
|
|
164
|
+
if (this.m_touch_count == 2) {
|
|
165
|
+
this.m_touch_count = 0;
|
|
166
|
+
// dirty fake dblclick event
|
|
165
167
|
const tch = ev.touches[0];
|
|
168
|
+
let fake = { type: "dblclick" };
|
|
166
169
|
for (const n in tch) {
|
|
167
170
|
fake[n] = tch[n];
|
|
168
171
|
}
|
|
169
|
-
//
|
|
172
|
+
// ignore -> private: dirty x2
|
|
170
173
|
component_1.Component._dispatchEvent(fake);
|
|
171
|
-
ev.preventDefault();
|
|
172
174
|
ev.stopPropagation();
|
|
173
175
|
}
|
|
174
176
|
});
|
package/lib/router.js
CHANGED
|
@@ -53,7 +53,7 @@ function parseRoute(str, loose = false) {
|
|
|
53
53
|
const o = tmp.indexOf('?', 1);
|
|
54
54
|
const ext = tmp.indexOf('.', 1);
|
|
55
55
|
keys.push(tmp.substring(1, o >= 0 ? o : ext >= 0 ? ext : tmp.length));
|
|
56
|
-
pattern += o
|
|
56
|
+
pattern += o >= 0 && ext < 0 ? '(?:/([^\/]+?))?' : '/([^\/]+?)';
|
|
57
57
|
if (ext >= 0) {
|
|
58
58
|
pattern += (o >= 0 ? '?' : '') + '\\' + tmp.substring(ext);
|
|
59
59
|
}
|
package/package.json
CHANGED
package/src/application.ts
CHANGED
|
@@ -34,6 +34,8 @@ import { Settings } from './settings'
|
|
|
34
34
|
import { deferCall } from './tools'
|
|
35
35
|
import { _tr } from './i18n'
|
|
36
36
|
|
|
37
|
+
const _x4_touch_time = Symbol( );
|
|
38
|
+
|
|
37
39
|
|
|
38
40
|
interface ApplicationEventMap extends BaseComponentEventMap {
|
|
39
41
|
message: EvMessage;
|
|
@@ -92,6 +94,9 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
92
94
|
|
|
93
95
|
private m_local_storage: Settings;
|
|
94
96
|
private m_user_data: any;
|
|
97
|
+
|
|
98
|
+
private m_touch_time: number;
|
|
99
|
+
private m_touch_count: number;
|
|
95
100
|
|
|
96
101
|
constructor( props : P ) {
|
|
97
102
|
console.assert( Application.self===null, 'application is a singleton' );
|
|
@@ -104,6 +109,9 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
104
109
|
let settings_name = `${this.m_app_name}.${this.m_app_version}.settings`;
|
|
105
110
|
this.m_local_storage = new Settings( settings_name );
|
|
106
111
|
this.m_user_data = {};
|
|
112
|
+
|
|
113
|
+
this.m_touch_time = 0;
|
|
114
|
+
this.m_touch_count = 0;
|
|
107
115
|
|
|
108
116
|
(Application.self as any) = this;
|
|
109
117
|
|
|
@@ -195,37 +203,31 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
195
203
|
public enterModal( enter: boolean ) {
|
|
196
204
|
}
|
|
197
205
|
|
|
198
|
-
public
|
|
206
|
+
public enableTouchDblClick( ) {
|
|
199
207
|
document.addEventListener( 'touchstart', ( ev: TouchEvent ) => {
|
|
200
208
|
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if( !me.__last_touch || (me.__last_touch-now) > 700 ) {
|
|
205
|
-
me.__touch_cnt = 1;
|
|
209
|
+
let now = Date.now( );
|
|
210
|
+
if( (now-this.m_touch_time) > 700 ) {
|
|
211
|
+
this.m_touch_count = 1;
|
|
206
212
|
}
|
|
207
213
|
else {
|
|
208
|
-
|
|
214
|
+
this.m_touch_count++;
|
|
209
215
|
}
|
|
210
216
|
|
|
211
|
-
|
|
217
|
+
this.m_touch_time = now;
|
|
212
218
|
|
|
213
|
-
if(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
let fake = {
|
|
217
|
-
type: "dblclick",
|
|
218
|
-
};
|
|
219
|
+
if( this.m_touch_count==2 ) {
|
|
220
|
+
this.m_touch_count = 0;
|
|
219
221
|
|
|
222
|
+
// dirty fake dblclick event
|
|
220
223
|
const tch = ev.touches[0];
|
|
224
|
+
let fake: any = {type: "dblclick" };
|
|
221
225
|
for( const n in tch ) {
|
|
222
226
|
fake[n] = tch[n];
|
|
223
227
|
}
|
|
224
228
|
|
|
225
|
-
//
|
|
229
|
+
// ignore -> private: dirty x2
|
|
226
230
|
(Component as any)._dispatchEvent( fake );
|
|
227
|
-
|
|
228
|
-
ev.preventDefault( );
|
|
229
231
|
ev.stopPropagation( );
|
|
230
232
|
}
|
|
231
233
|
});
|
package/src/router.ts
CHANGED
|
@@ -72,7 +72,7 @@ function parseRoute(str: string | RegExp, loose = false): Segment {
|
|
|
72
72
|
const ext = tmp.indexOf('.', 1);
|
|
73
73
|
|
|
74
74
|
keys.push(tmp.substring(1, o >= 0 ? o : ext >= 0 ? ext : tmp.length));
|
|
75
|
-
pattern += o
|
|
75
|
+
pattern += o >= 0 && ext < 0 ? '(?:/([^\/]+?))?' : '/([^\/]+?)';
|
|
76
76
|
if (ext >= 0) {
|
|
77
77
|
pattern += (o >= 0 ? '?' : '') + '\\' + tmp.substring(ext);
|
|
78
78
|
}
|