x4js 2.0.21 → 2.0.22

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.
@@ -1293,6 +1293,7 @@ declare module 'x4js' {
1293
1293
  }
1294
1294
 
1295
1295
  export interface CanvasProps extends ComponentProps {
1296
+ paint_cb: (ctx: CanvasEx ) => void;
1296
1297
  paint: EventCallback<EvPaint>;
1297
1298
  clear?: boolean;
1298
1299
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "X4 framework",
5
5
  "author": "etienne cochard",
6
6
  "license": "MIT",
@@ -30,8 +30,9 @@ interface CanvasEventMap extends ComponentEvents {
30
30
  }
31
31
 
32
32
  export interface CanvasProps extends ComponentProps {
33
- paint: EventCallback<EvPaint>
34
- clear?: boolean;
33
+ paint_cb: (ctx: CanvasEx ) => void; // simple callback
34
+ paint: EventCallback<EvPaint> // or standard event (slower)
35
+ clear?: boolean; // clear background before painting
35
36
  }
36
37
 
37
38
 
@@ -179,7 +180,12 @@ export class Canvas extends Component<CanvasProps, CanvasEventMap> {
179
180
 
180
181
  protected paint(ctx: CanvasEx ) {
181
182
  try {
182
- this.fire('paint', { ctx } );
183
+ if( this.props.paint_cb ) {
184
+ this.props.paint_cb( ctx );
185
+ }
186
+ else {
187
+ this.fire('paint', { ctx } );
188
+ }
183
189
  }
184
190
  catch (x) {
185
191
  console.assert(false, x);