x4js 2.0.24 → 2.0.26

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.
@@ -14,7 +14,7 @@
14
14
  * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
15
  **/
16
16
 
17
- import { Component, ComponentProps, Flex } from '../../core/component';
17
+ import { Component } from '../../core/component';
18
18
  import { Box, BoxProps, Button, HBox, VBox } from '../components';
19
19
  import { _tr } from '../../core/core_i18n';
20
20
 
@@ -107,7 +107,7 @@ export class Keyboard extends HBox<KeyboardProps>
107
107
  keyboard: Box;
108
108
  visible: boolean;
109
109
  input: HTMLInputElement;
110
-
110
+
111
111
  constructor( props: KeyboardProps ) {
112
112
  super( { ...props, id: 'v-keyboard' } );
113
113
 
@@ -140,11 +140,15 @@ export class Keyboard extends HBox<KeyboardProps>
140
140
  });
141
141
  }
142
142
 
143
+ setZoom( perc: number ) {
144
+ this.setStyleVariable( '--keyboard-zoom', perc+'%' );
145
+ }
146
+
143
147
  /**
144
148
  *
145
149
  */
146
150
 
147
- handleKey( e: UIEvent ) {
151
+ private handleKey( e: UIEvent ) {
148
152
  let target = e.target as HTMLElement;
149
153
  let key;
150
154
 
@@ -238,19 +242,17 @@ export class Keyboard extends HBox<KeyboardProps>
238
242
  *
239
243
  */
240
244
 
241
- _redraw( ) {
245
+ private _redraw( ) {
242
246
  this.setContent( [
243
- new Flex( ),
244
247
  this.keyboard = new VBox( {
245
248
  id: "kb",
246
249
  cls: this.mode,
247
250
  content: this._createContent( ),
248
251
  }),
249
- new Flex( ),
250
252
  ] );
251
253
  }
252
254
 
253
- _scrollIntoView( el: HTMLElement ) {
255
+ private _scrollIntoView( el: HTMLElement ) {
254
256
 
255
257
  let parent = el.parentElement ;
256
258
 
@@ -275,7 +277,7 @@ export class Keyboard extends HBox<KeyboardProps>
275
277
  //el.scrollIntoView( false );
276
278
  }
277
279
 
278
- _updateVis = ( ) => {
280
+ private _updateVis = ( ) => {
279
281
 
280
282
  if( this.visible ) {
281
283
  if( this.input ) {
@@ -149,11 +149,17 @@ class SvgItem {
149
149
  */
150
150
 
151
151
  getAttr( name: string ) : string {
152
- return this._dom.getAttribute( name );
152
+ const a = this._dom.getAttribute( name ) || '';
153
+ return a;
153
154
  }
154
155
 
155
156
  getNumAttr( name: string ) {
156
- return parseInt( this._dom.getAttribute( name ) );
157
+ const a = this._dom.getAttribute( name )
158
+ if( a=='' ) {
159
+ return 0;
160
+ }
161
+
162
+ return parseInt( a );
157
163
  }
158
164
 
159
165
  /**
@@ -164,7 +170,12 @@ class SvgItem {
164
170
  */
165
171
 
166
172
  setAttr( name: string, value: string ) : this {
167
- this._dom.setAttribute( name, value );
173
+ if( value===null || value===undefined ) {
174
+ this._dom.removeAttribute( name );
175
+ }
176
+ else {
177
+ this._dom.setAttribute( name, value );
178
+ }
168
179
  return this;
169
180
  }
170
181
 
@@ -238,12 +249,18 @@ class SvgItem {
238
249
  return this;
239
250
  }
240
251
 
252
+
241
253
  /**
242
254
  *
243
255
  */
244
256
 
245
257
  transform( tr: string ): this {
246
- const t = this.getAttr( "transform" ) ?? "";
258
+ this.setAttr( "transform", tr );
259
+ return this;
260
+ }
261
+
262
+ add_transformation( tr: string ): this {
263
+ const t = this.getAttr( "transform" );
247
264
  this.setAttr( "transform", t+' '+tr );
248
265
  return this;
249
266
  }
@@ -262,16 +279,32 @@ class SvgItem {
262
279
  return this;
263
280
  }
264
281
 
282
+ add_rotation( deg: number, cx: number, cy: number ): this {
283
+ this.add_transformation( `rotate( ${deg} ${cx} ${cy} )` );
284
+ return this;
285
+ }
286
+
265
287
  translate( dx: number, dy: number ): this {
266
288
  this.transform( `translate( ${dx} ${dy} )` );
267
289
  return this;
268
290
  }
269
291
 
292
+ add_translation( dx: number, dy: number ): this {
293
+ this.add_transformation( `translate( ${dx} ${dy} )` );
294
+ return this;
295
+ }
296
+
270
297
  scale( x: number ): this {
271
298
  this.transform( `scale( ${x} )` );
272
299
  return this;
273
300
  }
274
301
 
302
+ add_scale( x: number ): this {
303
+ this.add_transformation( `scale( ${x} )` );
304
+ return this;
305
+ }
306
+
307
+
275
308
  /**
276
309
  *
277
310
  */