nativescript-community / ui-canvas

Implement Canvas into your NativeScript apps.
https://nativescript-community.github.io/ui-canvas/
Apache License 2.0
31 stars 9 forks source link

Canvas reference in CanvasView object #15

Closed SntsDev closed 4 years ago

SntsDev commented 4 years ago

Hi @farfromrefug, thanks for you work here. I want to know why you aren't exposing the Canvas as a property of the CanvasView.

I'm using Svelte-Native, which closely follows Nativescript-Vue, but it's not yet finished. The problem is that the "draw" callback is not passed/called.

When I add a listener: cnvObj._nativeElement.on("draw", canvasLoaded); I get an event with the eventName and an object, but this last is the CanvasView object. Therefore, the code to draw can't work as it can't get a reference to the Canvas in this event.

Can you expose the Canvas object as a property of the CanvasView object? Or what's the reason behind not doing it?

Thanks

farfromrefug commented 4 years ago

@SntsDev I cant really tell how you use it. But i can tell you it works perfectly with svelte. Here is working example: https://github.com/farfromrefug/ns-forecastie/blob/cf088d167cd8753eb2c964baad818131b89849bc/app/WeatherCollectionItem.svelte#L115 I will close that issue for now. If you think there is still an issue let me know.

SntsDev commented 4 years ago

Thanks @farfromrefug, I don't know why I missed to add "on" to on:draw={...}. You're totally right. Thank you!