Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

加载看板娘的时候我的界面动画卡卡的,能排一下加载顺序,最后加载看板娘吗? #108

Open
1 task
zhangao4833 opened this issue May 2, 2018 · 9 comments
Labels

Comments

@zhangao4833
Copy link

Issue

Description

Expected behavior 预期行为

Actual behavior 实际行为

Steps to reproduce the behavior 复现步骤

Change the [ ] into [x] to show your acceptance.
[ ] 变为 [x] 来表示你接受了这些问题。

@EYHN @xiazeyu

@EYHN
Copy link
Owner

EYHN commented May 2, 2018

简单 setTimeout 就可以了

@EYHN EYHN added the feature label May 2, 2018
@zhangao4833
Copy link
Author

我还不知道加在哪,正在尝试。

@zhangao4833
Copy link
Author

还得请教下应该加在哪,实在是找不到地方加@EYHN

@zhangao4833
Copy link
Author

@EYHN 在哪加,速回,-_-|| 眼睛快找瞎了 O(∩_∩)O

@EYHN
Copy link
Owner

EYHN commented May 2, 2018

https://github.com/EYHN/hexo-helper-live2d/blob/master/index.js#L186

const scriptToInject = `L2Dwidget.init(${JSON.stringify(config)});`;
// --------->
const scriptToInject = `setTimeout(function (){L2Dwidget.init(${JSON.stringify(config)})}, 500);`;

@zhangao4833
Copy link
Author

我试了下,没有效果。我将setTime的值都 设为 10000了 他还是秒加载 然后主题动画就和他一起加载就会卡顿。

@EYHN
Copy link
Owner

EYHN commented May 2, 2018

@zhangao4833 上面的代码更新

@xiazeyu
Copy link
Collaborator

xiazeyu commented May 4, 2018

能否提供详细的页面地址?
你所说的卡顿是模型加载完成后卡顿,还是刚打开网页,模型未加载出来时卡顿?是整个页面包括拖动也卡顿还是只是主题动画卡顿?

@xiazeyu
Copy link
Collaborator

xiazeyu commented May 12, 2018

@zhangao4833
https://www.webpackjs.com/guides/code-splitting/#%E5%8A%A8%E6%80%81%E5%AF%BC%E5%85%A5-dynamic-imports-

由于 import() 会返回一个 promise,因此它可以和 async 函数一起使用。但是,需要使用像 Babel 这样的预处理器和Syntax Dynamic Import Babel Plugin。下面是如何通过 async 函数简化代码:

理论上加载主脚本是异步的,而且主脚本巨大无比(~145.54 KB),应该不会因为下载而造成太大卡顿。现在有一种解决方案,就是判断如果您的fps值稳定,再加载。但是请确定一下是否的确是一开始加载太快导致卡顿。
您可以先不使用hexo-helper-live2d

然后进入您的网站手动在控制台输入

a = document.createElement('script')
a.src = 'https://cdn.jsdelivr.net/npm/[email protected]/lib/L2Dwidget.min.js'
document.body.appendChild(a)
L2Dwidget.init()

观察是否卡顿。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants