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.
- package/lib/cjs/x4.js +1 -1
- package/lib/esm/x4.mjs +1 -1
- package/lib/types/x4js.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/canvas/canvas.ts +9 -3
package/lib/types/x4js.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -30,8 +30,9 @@ interface CanvasEventMap extends ComponentEvents {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface CanvasProps extends ComponentProps {
|
|
33
|
-
|
|
34
|
-
|
|
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.
|
|
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);
|