类更新不会将背景加载到SVG中 [英] Class update not load background into SVG

查看:55
本文介绍了类更新不会将背景加载到SVG中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个适用于Android的Ionic应用程序.在该应用程序上,有一个类似于卡片"的内容,用户可以在其中通过侧面菜单选项(选择)应用自定义背景图片.

I have an Ionic App made for Android. On the app, there's a "card" like content in which the user apply custom background images through a side-menu options (selects).

这些选项更改了容器上的某些类,因此它根据类接收不同的背景图像.

These options change some classes on the container, so it receive diferent background-images according to class.

自定义后,用户按下创建"按钮,将卡呈现为SVG,然后呈现为Canvas,以便我可以检索dataURL图像以共享或保存在手机上.

After the customization the user press a "create" button that render the card to a SVG then to a Canvas so I could retrieve the dataURL image to share or save on phone.

我正在使用插件 dom-to-image 来呈现卡片.

I'm using the plugin dom-to-image, to render the card.

但是在类更改后,渲染的内容没有接收到背景.

But the rendered content don't receive the backgrounds after the class changes.

我注意到,如果在更改之后但在点击按钮之前,我给了更多时间" .它可以正确渲染.因此,我在调用渲染器之前放置了setTimeout,但是没有确切的时间计数,并且背景图像仍然没有出现.

I noticed that if I give more "time" after the change but before hit the button. It render properly. So I put an setTimeout before calling the render, but there's not an exact time count and the background-image still don't appear.

你们能启发我吗?更新类过程是否会干扰SVG画布内容?

Can you guys enlighten me?? There's any problem with that update class process interfering with the SVG to Canvas content?

我使用的是插件而不是我自己的原始代码,因为内容具有,嵌入字体,css样式和其他样式.除了背景图像之外,其他所有东西都可以正确渲染.

I'm using a plugin instead of my raw own code because the content has, embed fonts, css styles and other stufs. Everything render properly except the background-images...

该问题仅在移动设备上发生.提前谢谢!

The problem only happen on mobile. Thx in advance!

推荐答案

我发现发生这种情况是因为插件未在渲染的时间"内注册内容更新.

I discover that this occurs because the content update is not registered by the plugin in "time" to it render.

angular指令,css类等太慢".最好的方法是将特征背景图像更改为具有src属性的img.

The angular directives, css classes and so on are too "slow". The best way is to change the feature background-image to an img with src attribute.

当您必须更新内容时,只需更新img src属性并更新即可!

When you have to update the content, just update the img src attribute and voilà!

这篇关于类更新不会将背景加载到SVG中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆