Is it possible to render a vue component offscreen and convert to an image? - vue.js

I'm implementing a drag and drop grid dashboard similar to cryptotiles.io or microsoft's powerbi. I have the grid working using vue-grid-layout. I want to now implement a drawer to add in more tiles. Would it be possible to render a component on plan on displaying on the grid onto an offscreen canvas. From there convert that to an image and use the image as a preview so that user's know what the component kind of looks like before adding it to the actual grid?
edit: html2canvas offscreen
I found this. I'm wondering if adding to the dom off the window somehow to make a thumbnail would affect performance?

Related

Adjust font size dynamically in a FlatList in React Native

Before I begin trying to build something I want to check my strategy.
I think the best way to define what I would like to achieve is to build a component using a FlatList that adjusts fontSize dynamically based on the size of the View (or other more appropriately defined size limiting area) in which it is being displayed.
For example, let's say I want a FlatList of items (of data returned from an API call) that displays full-screen on Screen 1 of my app, but in a small corner of Screen 2 of my app. Here's a quick mock of the behavior I would want:
It seems like the alignment of items, flex, other styles could be written so that the proportions/positions stay the same regardless of parent view in which the FlatList is displayed, so I might only have to adjust fontSize.
Can this behavior be achieved using a FlatList and a reference to a dynamic fontSize? If so, where should the "awareness" of the parent View be stored/passed?
I'm looking for general input as to how to achieve this simply, with or without FlatList. I like using FlatList because of how well it works off the shelf for my simple tasks. Hopefully I'm not trying to make it do something it cant.
Thanks!

How to detect map container resize due to slow loading image?

I am creating an app with a Leaflet map in Nuxt using Vue2Leaflet plugin.
I am having a problem though: I am using Bootstrap columns to size the map and accompanying image, but the image loads too slow (this cannot be resolved at this time), so the container is not the proper size when the map loads.
This causes the map to be half grey. I have attempted to call map.invalidateSize() in the mounted event, but even that must be happening before the image finishes loading.
I have setup a sandbox at: https://codesandbox.io/s/eager-bohr-c3453?file=/src/App.vue
In order to see the bug, you have to view the rendered app at https://c3453.csb.app/ (the internal codesandbox render does not show the problem)
I think I need some way to wait until the image has completed loading (so the BS col is the proper size), then call map.invalidateSize(), but I am not sure how...
You can attach an onload listener on your <img>, so that you can call (again?) your Leaflet map invalidateSize() method.

codename one how to place component on an image viewer that capture camera?

I have a GUI Builder created form in codename one, how can i open the camera in a resizable view at the show() of the form and place container like text area or anything else on it?
I saw the camera demo but i don't understand it very well because on the simulator it open a file picker.
My purpose is to create a form with a camera resizable capture when you have two labels and you can also write or paint on your photo used in background, I do this only for hobby and fun, i do what i can, Any advice is well accepted, thank you for the attenction
You can now place a component on top of a camera view with a new cn1lib: https://github.com/codenameone/CameraKitCodenameOne
Original answer below:
I'm assuming you mean overlay on a live camera view. While this is possible it's not supported at this time in the Java API layer.
If you mean grabbing a photo and setting it as a background for the form for overlay you can create an image with the result of the Capture API and use setBgImage() to set that image to the background of a component or form.

Hide image while loading new source

I've implemented a React Native component which shows an image loaded from a remote server. The user can swipe the image out of the screen in order to navigate to the next image which is again loaded from the remote server. While loading of the second image, the old image is still visible on the screen.
I want the old image to disappear while loading the next image. Any hint how to achieve this?
Prop defaultSource only works for initial render (showing the first image) but not consecutive images. So I guess React reuses the Image under the hood. I've played around with onLoadStart and onLoadEnd but I don't know how to reset the source of the old image.
Any idea?
Thanks.
Add a unique key prop to each image. It can be a number or a string. That will prevent React from re-using the elements.

White Flash inbetween Re-rendering Image Views

Not sure if this is a huge issue, but I am not completely sure a solution exists to this.
When creating a slideshow style element, where upon tap you image changes to another image (already prefetched using React Native's image prefetcher) there is this white flash when the screen re-renders (I think?).
Has there been a concrete solution to this? I can't figure out how something like say a snapchat story manages to render a new image completely instant
Has anyone ever done this? is the strategy to just load one image on top of another?