1
- import { isNodeJs , isBatchMode , setBatchMode , postponePromise } from './core.mjs' ;
1
+ import { isNodeJs , isFunc , isBatchMode , setBatchMode , postponePromise } from './core.mjs' ;
2
2
import { select as d3_select } from './d3.mjs' ;
3
3
import { _loadJSDOM } from './base/BasePainter.mjs' ;
4
4
import { cleanup , getElementCanvPainter } from './base/ObjectPainter.mjs' ;
@@ -51,7 +51,8 @@ function _getAllSubPads(cp) {
51
51
async function testZooming ( node , args , pp ) {
52
52
const cp = getElementCanvPainter ( node ) ,
53
53
pad_painter = pp ?? cp ;
54
- if ( ! pad_painter ) return ;
54
+ if ( ! pad_painter )
55
+ return ;
55
56
const fp = pad_painter . getFramePainter ( ) ;
56
57
if ( ! fp && ! pp ) {
57
58
const sub_pads = _getAllSubPads ( cp ) ;
@@ -60,8 +61,10 @@ async function testZooming(node, args, pp) {
60
61
return ;
61
62
}
62
63
63
- if ( ( typeof fp ?. zoom !== 'function' ) || ( typeof fp ?. zoomSingle !== 'function' ) ) return ;
64
- if ( typeof fp . scale_xmin === 'undefined' || typeof fp . scale_ymax === 'undefined' ) return ;
64
+ if ( ! isFunc ( fp ?. zoom ) || ! isFunc ( fp ?. zoomSingle ) )
65
+ return ;
66
+ if ( typeof fp . scale_xmin === 'undefined' || typeof fp . scale_ymax === 'undefined' )
67
+ return ;
65
68
66
69
const xmin = fp . scale_xmin , xmax = fp . scale_xmax , ymin = fp . scale_ymin , ymax = fp . scale_ymax ;
67
70
@@ -83,7 +86,8 @@ async function testZooming(node, args, pp) {
83
86
async function testMouseZooming ( node , args , pp ) {
84
87
const cp = getElementCanvPainter ( node ) ,
85
88
pad_painter = pp ?? cp ;
86
- if ( ! pad_painter ) return ;
89
+ if ( ! pad_painter )
90
+ return ;
87
91
const fp = pad_painter . getFramePainter ( ) ;
88
92
89
93
if ( ! fp && ! pp ) {
@@ -93,10 +97,12 @@ async function testMouseZooming(node, args, pp) {
93
97
return ;
94
98
}
95
99
96
- if ( fp ?. mode3d ) return ;
100
+ if ( fp ?. mode3d )
101
+ return ;
97
102
if ( ( typeof fp ?. startRectSel !== 'function' ) ||
98
103
( typeof fp ?. moveRectSel !== 'function' ) ||
99
- ( typeof fp ?. endRectSel !== 'function' ) ) return ;
104
+ ( typeof fp ?. endRectSel !== 'function' ) )
105
+ return ;
100
106
101
107
const fw = fp . getFrameWidth ( ) , fh = fp . getFrameHeight ( ) ,
102
108
evnt = new EmulationMouseEvent ( ) ,
@@ -132,7 +138,8 @@ async function testMouseZooming(node, args, pp) {
132
138
async function testTouchZooming ( node , args , pp ) {
133
139
const cp = getElementCanvPainter ( node ) ,
134
140
pad_painter = pp ?? cp ;
135
- if ( ! pad_painter ) return ;
141
+ if ( ! pad_painter )
142
+ return ;
136
143
const fp = pad_painter . getFramePainter ( ) ;
137
144
138
145
if ( ! fp && ! pp ) {
@@ -142,10 +149,8 @@ async function testTouchZooming(node, args, pp) {
142
149
return ;
143
150
}
144
151
145
- if ( fp ?. mode3d ) return ;
146
- if ( ( typeof fp ?. startTouchZoom !== 'function' ) ||
147
- ( typeof fp ?. moveTouchZoom !== 'function' ) ||
148
- ( typeof fp ?. endTouchZoom !== 'function' ) ) return ;
152
+ if ( fp ?. mode3d || ! isFunc ( fp ?. startTouchZoom ) || ! isFunc ( fp ?. moveTouchZoom ) || ! isFunc ( fp ?. endTouchZoom ) )
153
+ return ;
149
154
150
155
const fw = fp . getFrameWidth ( ) , fh = fp . getFrameHeight ( ) ,
151
156
evnt = new EmulationMouseEvent ( ) ;
@@ -176,7 +181,8 @@ async function testTouchZooming(node, args, pp) {
176
181
async function testMouseWheel ( node , args , pp ) {
177
182
const cp = getElementCanvPainter ( node ) ,
178
183
pad_painter = pp ?? cp ;
179
- if ( ! pad_painter ) return ;
184
+ if ( ! pad_painter )
185
+ return ;
180
186
const fp = pad_painter . getFramePainter ( ) ;
181
187
182
188
if ( ! fp && ! pp ) {
@@ -186,8 +192,8 @@ async function testMouseWheel(node, args, pp) {
186
192
return ;
187
193
}
188
194
189
- if ( fp ?. mode3d ) return ;
190
- if ( typeof fp ?. mouseWheel !== 'function' ) return ;
195
+ if ( fp ?. mode3d || ! isFunc ( fp ?. mouseWheel ) )
196
+ return ;
191
197
192
198
const fw = fp . getFrameWidth ( ) , fh = fp . getFrameHeight ( ) ,
193
199
evnt = new EmulationMouseEvent ( ) ,
@@ -218,7 +224,8 @@ async function testMouseWheel(node, args, pp) {
218
224
async function testFrameClick ( node , pp ) {
219
225
const cp = getElementCanvPainter ( node ) ,
220
226
pad_painter = pp ?? cp ;
221
- if ( ! pad_painter ) return ;
227
+ if ( ! pad_painter )
228
+ return ;
222
229
const fp = pad_painter . getFramePainter ( ) ;
223
230
224
231
if ( ! fp && ! pp ) {
@@ -228,7 +235,8 @@ async function testFrameClick(node, pp) {
228
235
return ;
229
236
}
230
237
231
- if ( fp ?. mode3d || typeof fp ?. processFrameClick !== 'function' ) return ;
238
+ if ( fp ?. mode3d || ! isFunc ( fp ?. processFrameClick ) )
239
+ return ;
232
240
233
241
const fw = fp . getFrameWidth ( ) , fh = fp . getFrameHeight ( ) ;
234
242
@@ -243,7 +251,8 @@ async function testFrameClick(node, pp) {
243
251
async function testFrameMouseDoubleClick ( node , pp ) {
244
252
const cp = getElementCanvPainter ( node ) ,
245
253
pad_painter = pp ?? cp ;
246
- if ( ! pad_painter ) return ;
254
+ if ( ! pad_painter )
255
+ return ;
247
256
const fp = pad_painter . getFramePainter ( ) ;
248
257
249
258
if ( ! fp && ! pp ) {
@@ -253,7 +262,8 @@ async function testFrameMouseDoubleClick(node, pp) {
253
262
return ;
254
263
}
255
264
256
- if ( fp ?. mode3d || typeof fp ?. mouseDoubleClick !== 'function' ) return ;
265
+ if ( fp ?. mode3d || ! isFunc ( fp ?. mouseDoubleClick ) )
266
+ return ;
257
267
258
268
const fw = fp . getFrameWidth ( ) , fh = fp . getFrameHeight ( ) ,
259
269
evnt = new EmulationMouseEvent ( ) ,
@@ -270,7 +280,8 @@ async function testFrameMouseDoubleClick(node, pp) {
270
280
async function testFrameContextMenu ( node , args , pp ) {
271
281
const cp = getElementCanvPainter ( node ) ,
272
282
pad_painter = pp ?? cp ;
273
- if ( ! pad_painter ) return ;
283
+ if ( ! pad_painter )
284
+ return ;
274
285
const fp = pad_painter . getFramePainter ( ) ;
275
286
276
287
if ( ! fp && ! pp ) {
@@ -280,7 +291,8 @@ async function testFrameContextMenu(node, args, pp) {
280
291
return ;
281
292
}
282
293
283
- if ( fp ?. mode3d || typeof fp ?. showContextMenu !== 'function' ) return ;
294
+ if ( fp ?. mode3d || ! isFunc ( fp ?. showContextMenu ) )
295
+ return ;
284
296
285
297
const fw = fp . getFrameWidth ( ) , fh = fp . getFrameHeight ( ) ,
286
298
evnt = new EmulationMouseEvent ( ) ,
@@ -315,7 +327,8 @@ async function testPadContextMenu(node, args, pp) {
315
327
await testPadContextMenu ( node , args , sub_pads [ k ] ) ;
316
328
}
317
329
318
- if ( typeof cp ?. padContextMenu !== 'function' ) return ;
330
+ if ( ! isFunc ( cp ?. padContextMenu ) )
331
+ return ;
319
332
320
333
const pw = cp . getPadWidth ( ) , ph = cp . getPadHeight ( ) ,
321
334
evnt = new EmulationMouseEvent ( ) ,
@@ -340,7 +353,7 @@ async function testPadItemContextMenu(node, args, pp) {
340
353
await testPadItemContextMenu ( node , args , sub_pads [ k ] ) ;
341
354
}
342
355
343
- if ( typeof cp ?. itemContextMenu !== 'function' )
356
+ if ( ! isFunc ( cp ?. itemContextMenu ) )
344
357
return ;
345
358
346
359
const nprimitives = cp . getNumPainters ( ) ?? 0 ,
@@ -356,7 +369,8 @@ async function testPadItemContextMenu(node, args, pp) {
356
369
357
370
async function testPadButtons ( node , args ) {
358
371
const cp = getElementCanvPainter ( node ) ;
359
- if ( typeof cp ?. clickPadButton !== 'function' ) return ;
372
+ if ( ! isFunc ( cp ?. clickPadButton ) )
373
+ return ;
360
374
361
375
const evnt = new EmulationMouseEvent ( 50 , 50 ) ,
362
376
toggles = [ 'ToggleZoom' , 'ToggleLogX' , 'ToggleLogY' , 'ToggleLogZ' , 'Toggle3D' , 'ToggleColorZ' , 'ToggleStatBox' ] ;
0 commit comments