Coder Social home page Coder Social logo

svga / svgaplayer-web Goto Github PK

View Code? Open in Web Editor NEW
934.0 29.0 236.0 7.15 MB

Similar to Lottie. Render After Effects / Animate CC (Flash) animations natively on Android and iOS, Web. 使用 SVGAPlayer 在 Android、iOS、Web中播放 After Effects / Animate CC (Flash) 动画。

Home Page: https://svga.io

License: Apache License 2.0

HTML 0.67% JavaScript 99.33%

svgaplayer-web's Introduction

Archived

本仓库已经停止维护,你仍然继续阅读源码及创建分叉,但本仓库不会继续更新,也不会回答任何 issue。

This repo has stopped maintenance, you can still continue to read the source code and create forks, but this repo will not continue to be updated, nor will it answer any issues.

SVGAPlayer-Web

Language: 中文

SVGAPlayer 现已支持在微信小程序播放动画,详情请参阅

支持本项目

  1. 轻点 GitHub Star,让更多人看到该项目。

News

Can I Use

SVGAPlayer 2.0.0 only supports below browsers.

  • Edge / IE 6+
  • Safari / Chrome
  • iOS 6.0+ / Android 4.0+

SVGAPlayer 2.0.0 also supports below Game Engines.

Install

Prebuild JS

  1. Add <script src="https://cdn.jsdelivr.net/npm/[email protected]/build/svga.min.js"></script> to your.html

NPM

  1. npm install svgaplayerweb --save
  2. Add require('svgaplayerweb') to xxx.js

IE6 ~ IE9

  • IE6+ only supports 2.x format.
  • You couldn't use npm to install SVGA library.
  1. Add SVGAPlayerWeb.swf to your.html locate directory.
  2. Add following code to your.html
<!--[if lt IE 10]> 
    <script src="../build/svga.ie.min.js"></script>
<![endif]-->
<!--[if gte IE 10]><!-->
    <script src="../build/svga.min.js"></script>
<!--<![endif]-->

Audio support

If your need to play audios, add howler.min.js to your html.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/howler.core.min.js"></script>

Notice: audio plays needs browser support, some browser requires user interaction before playing.

SVGA-Format 1.x support

Both Prebuild & NPM, if you need to support SVGA-Format 1.x, add JSZip script to html.

<script src="//s1.yy.com/ued_web_static/lib/jszip/3.1.4/??jszip.min.js,jszip-utils.min.js" charset="utf-8"></script>

Usage

Load Animation Mannally

You may create Player and Parser by yourself.

  1. Add Div Tag.
<div id="demoCanvas" style="styles..."></div>
  1. Load Animation
var player = new SVGA.Player('#demoCanvas');
var parser = new SVGA.Parser('#demoCanvas'); // Must Provide same selector eg:#demoCanvas IF support IE6+
parser.load('rose_2.0.0.svga', function(videoItem) {
    player.setVideoItem(videoItem);
    player.startAnimation();
})

Load Animation Automatically

Assign canvas element properties as below.

<div src="rose_2.0.0.svga" loops="0" clearsAfterStop="true" style="styles..."></div>

Animation will play after Web-Page onload.

Replace Animation Images Dynamically

You can replace specific image by yourself, ask your designer tell you the ImageKey.

player.setImage('http://yourserver.com/xxx.png', 'ImageKey');

Add Text on Animation Image Dynamically

You can add text on specific image, ask your designer tell you the ImageKey.

player.setText('Hello, World!', 'ImageKey');
player.setText({ 
    text: 'Hello, World!', 
    family: 'Arial',
    size: "24px", 
    color: "#ffe0a4",
    offset: {x: 0.0, y: 0.0}
}, 'ImageKey'); // customize text styles.

Classes

SVGA.Player

You use SVGA.Player controls animation play and stop.

Properties

  • int loops; - Animation loop count, defaults to 0 means infinity loop.
  • BOOL clearsAfterStop; - defaults to true, means player will clear all contents after stop.
  • string fillMode; - defaults to Forward,optional Forward / Backward,fillMode = Forward,Animation will pause on last frame while finished,fillMode = Backward , Animation will pause on first frame.

Methods

  • constructor (canvas); - first params could be '#id' or CanvasHTMLElement
  • startAnimation(reverse: boolean = false); - start animation from zero frame.
  • startAnimationWithRange(range: {location: number, length: number}, reverse: boolean = false); - start animation in [location, location+length] frame range.
  • pauseAnimation(); - pause animation on current frame.
  • stopAnimation(); - stop animation, clear contents while clearsAfterStop === true
  • setContentMode(mode: "Fill" | "AspectFill" | "AspectFit"); - Specific Scale Mode
  • setClipsToBounds(clipsToBounds: boolean); - Clips if image render out of box.
  • clear(); - force clear contents.
  • stepToFrame(frame: int, andPlay: Boolean); - stop to specific frame, play animation while andPlay === true
  • stepToPercentage(percentage: float, andPlay: Boolean); - stop to specific percentage, play animation while andPlay === true
  • setImage(image: string, forKey: string, transform: [a, b, c, d, tx, ty]); - Replace Animation Images Dynamically, transform is optional, transform could adjust replacing image.
  • setText(text: string | {text: string, family: string, size: string, color: string, offset: {x: float, y: float}}, forKey: string); - Add Text on Animation Image Dynamically
  • clearDynamicObjects(); - clear all dynamic objects.

Callback Method

  • onFinished(callback: () => void): void; - call after animation stop.
  • onFrame(callback: (frame: number): void): void; - call after animation specific frame rendered.
  • onPercentage(callback: (percentage: number): void): void; - call after animation specific percentage rendered.

SVGA.Parser

You use SVGA.Parser load VideoItem from remote or Base64 string.

Only Cross-Domain allow files could be loaded.

If you eager to load resources from Base64 or File, deliver as load(File) or load('data:svga/2.0;base64,xxxxxx').

Methods

  • constructor();
  • load(url: string, success: (videoItem: VideoEntity) => void, failure: (error: Error) => void): void;

Issues

Android 4.x Breaks

As known, some Android OS lack Blob support, add Blob Polyfill by yourself.

<script src="//cdn.bootcss.com/blob-polyfill/1.0.20150320/Blob.min.js"></script>

svgaplayer-web's People

Contributors

dependabot[bot] avatar errnull avatar f3n67u avatar liveme avatar maxlee avatar naeemo avatar ponycui avatar yiliashaw avatar zeayal avatar zhaofinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

svgaplayer-web's Issues

设置viewport后canvas尺寸自适应

设计师一般按照iphone6的尺寸(750x1334)制作动画,移动端使用viewport调整缩放比后,videoSize默认是大于容器的size(假定在iphone6展示一个全屏动画375x667 ),然后会导致动画区域缩放(不能填充容器),现在的解决方案是使用translate缩放,希望可以在player.js内部自适应一下viewport

SVGA跨域问题

用player.load()出现跨域

  1. cors在哪里添加
  2. 如何更改数据获取方式

setText方法 不传 family 属性 size属性也会失效

Attention

  • setText方法 不传 family 属性 size属性也会失效

Issue Template

Issue Description(setText方法 不传 family 属性 size属性也会失效)

How To Reappear(
在一个svga里面setText方法
this.player.setText({
text: '一个很长很长的标题',
size: '28px',
color: '#f5ce8c',
//family: 'microsoft yahei'
}, 'name')
)

Any Attachment(Provide a sample about your issue)

------ 中文分割线 ------

注意

  • 不要在 Issue 板块提问使用问题,Issue 板块只接受 Bug 反馈。
  • 如果遇到使用上的问题,仔细阅读 README。

Issue 模板

请尽量使用英文提交 Issue

请确切回答:问题的描述、重现方式、附件(提供一个 Demo 以重现问题)

setImage 中imageKeys是什么

setImage 中imageKeys是什么 ,问了下动画设计师,他不清楚imageKey是什么,是代表原动画中的图片名称吗?Player.setImage(r“../abc.png”, "d1.png");不好使

Compatibility problems in Chrome

Problem

Your sample has a problem in Chrome. It case exception like this:

Failed to load http://any.com/my_svga_file.svga: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
svga.min.js:1 TypeError: Cannot read property 'length' of null
    at i.push (svga.min.js:1)
    at Object.n (svga.min.js:1)
    at Object.load_viaProto (svga.min.js:1)
    at XMLHttpRequest.o.onloadend (svga.min.js:1)
load_viaProto @ svga.min.js:1
o.onloadend @ svga.min.js:1
XMLHttpRequest.send (async)
loadAssets @ svga.min.js:1
e.exports @ svga.min.js:1
value @ svga.min.js:1
value @ svga.min.js:1
(anonymous) @ 20180425.svga.html:18
svga.min.js:1 Uncaught TypeError: Cannot read property 'length' of null
    at i.push (svga.min.js:1)
    at Object.n (svga.min.js:1)
    at Object.load_viaProto (svga.min.js:1)
    at XMLHttpRequest.o.onloadend (svga.min.js:1)

Here is my origin html code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>test</title>
    <meta name="robots" content="all" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
    <meta name="format-detection" content="telephone=no" />
</head>
<body>

<div id="demoCanvas"></div>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/build/svga.min.js"></script>
<script type="text/javascript">
  var player = new SVGA.Player('#demoCanvas');
  var parser = new SVGA.Parser('#demoCanvas');
  parser.load('http://any.com/my_svga_file.svga', function(videoItem) {
      player.setVideoItem(videoItem);
      player.startAnimation();
  })
</script>
</body>
</html>

I just thought that it was my mistake. Actually it works perfectly in Safari

http://biuugames.huya.com/WX20180425-202527@2x_20180425.png

problem of installation for layabox

  1. Patch laya.webgl.js library
    Goto https://github.com/yyued/SVGAPlayer-Web/tree/master/patch/layabox Download laya.webgl.js
    Replace to {LayaProjectDir}/bin/libs/laya.webgl.js
  2. Prebuild JS
    Goto https://github.com/yyued/SVGAPlayer-Web/tree/master/build Download svga.layabox.min.js
    Add <script src="svga.layabox.min.js"></script> to index.html

这是两种安装方法,还是两个安装步骤?
我从上下文理解为步骤,因为第3个是可选的。

但是,出现了错误

TypeError: this.startCreate is not a function

然而如果我省略第1步,只做第二步,则运行正常,但仍然有另一个已知问题:issues11: SVGA.layabox undefined

报的这种错是什么原因呢?

在谷歌中报的错误
1、Failed to load file:///C:/Users/fzz/Desktop/lx/img/aa.svga: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
2、InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').

在uc中报的错误
1、XMLHttpRequest cannot load file:///C:/Users/fzz/Desktop/lx/img/aa.svga. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https,

2、InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer').

在火狐中预览是好的没有报错

使用flash版本svga问题

1.使用flash版本svga库,无法播放动画,问题原因:创建object对象成功,但是并没有下载swf文件(目录下有SVGAPlayerWeb.swf)
2.修改添加object的代码,可以成功下载swf,并且执行了test.svga的下载,但是没有看到播放效果
测试浏览器:chrome,IE10

<script src="./svga.ie.min.js"></script>
  <script> 
    var player = new SVGA.Player('#test');
    var parser = new SVGA.Parser('#test'); 
    parser.load('test.svga', function(videoItem) {
        player.setVideoItem(videoItem);
        player.startAnimation();
    });
</script>

drawOnCanvas.html 报错:Cannot read property 'querySelectorAll' of undefined

npm start 后打开 http://127.0.0.1:8080/tests/drawOnCanvas.html 页面报错:

Uncaught TypeError: Cannot read property 'querySelectorAll' of undefined
    at Player._init (player.js:20)
    at Player (player.js:15)
    at new Player (svga.min.js:11699)
    at drawOnCanvas.html:12

看了下具体的原因是 var player = new SVGA.Player() 中没有指定 container,所以导致 player.js 中的 this._containerundefined

loops设置无效

html:
<div id="demoCanvas" loops="1"></div>

动画仍然无限循环播放

请问什么时候支持小程序端?

YY旗下的 “一件” App,已经支持小程序。并且也有和 App 端相同的动画。

我们了解到 “一件” App 移动端的动画使用的正是 SVGA。

所以我们想请问一下 小程序版本的 SVGAPlayer 有计划推出吗?

序列帧动画导出有问题

在使用SVGA AE Converter的时候,发现序列帧素材无法导出,也无法播放(把导出的1.5版本svga解压后,发现只有一张png素材).
对于纯图形的动画导出没有问题,可以在网页上播放

引入gif文件整个页面都在抖动

本来开发没什么问题。svga文件能正常显示,引进gif动画图片后,前几次能正常显示,后面有车次不知道为什吗报了错,说svga.min.js。里的length出错了,好像是,然后再渲染就是页面一直抖动了,重启项目,重启电脑也没用,请问是什么原因呢?不能使用gif文件吗?

svga文件跨域 怎么解决?

使用 parser.load() 方法加载同域下的 svga文件,没问题。但是其他域的svga文件报跨域错误。
怎么解决?

startAnimationWithRange 对于这个方法的一点建议

目前是播放指定区间的动画
建议:
参数改为数组,可以指定几段区间帧动画拼接播放,且在全部播放完之后才触发一次onfinsh
应用场景:
宝箱开出不同的礼物,如果说开出来的礼物是图片,那么用setImage 就够用了,但是如果开出来的是过渡动画,且礼物多样的情况下,那么可能需要很多个svga,其中,开宝箱的动作肯定是重复的,如果可以指定区间拼接播放的话,那么会节省很多空间

LayaboxPlayer在微信小游戏中报错

我试了一下,不在微信小游戏中,LayaboxPlayer可以正常。
但在微信小游戏下,加载二进制资源会报错:

const displayObject = new SVGA.LayaboxPlayer('http://127.0.0.1:8083/tests/samples/kingset.svga') displayObject.setFrame(0, 0, 750, 750); displayObject.zOrder = 100; Laya.stage.addChild(displayObject)
错误如下

VM383:1 TypeError: Function(...) is not a function
at r (bundle.main.js:21424)
at i.get (bundle.main.js:20759)
at i.nNlU.i.resolve (bundle.main.js:20254)
at i.nNlU.i.setup (bundle.main.js:20809)
at i.nNlU.i.decode (bundle.main.js:20818)
at Object.load_viaProto (bundle.main.js:21516)
at XMLHttpRequest.nNlU.l.loadAssets.o.onloadend (bundle.main.js:21510)
at XMLHttpRequest._triggerEvent (weapp-adapter.js? [sm]:1176)
at Function.success (weapp-adapter.js? [sm]:1302)
at Object.success (WAGame.js:4)
console.error @ VM383:1
load_viaProto @ bundle.main.js:21521
nNlU.l.loadAssets.o.onloadend @ bundle.main.js:21510
_triggerEvent @ weapp-adapter.js? [sm]:1176
success @ weapp-adapter.js? [sm]:1302
(anonymous) @ WAGame.js:4
(anonymous) @ WAGame.js:7
s.emit @ WAGame.js:5
(anonymous) @ WAGame.js:7
(anonymous) @ WAGame.js:4
a @ gamePage.html:1
(anonymous) @ gamePage.html:1
b.emit @ gamePage.html:1
callback @ gamePage.html:1
setTimeout @ gamePage.html:1
(anonymous) @ WAGame.js:4
(anonymous) @ WAGame.js:3
setTimeout (async)
setTimeout @ WAGame.js:3
n @ gamePage.html:1
c @ gamePage.html:1
v.onreadystatechange @ gamePage.html:1
XMLHttpRequest.send (async)
q @ gamePage.html:1
createRequestTask @ gamePage.html:1
invoke @ gamePage.html:1
r @ WAGame.js:4
c @ WAGame.js:4
r @ WAGame.js:7
e @ WAGame.js:7
(anonymous) @ WAGame.js:7
(anonymous) @ WAGame.js:6
send @ weapp-adapter.js? [sm]:1262
loadAssets @ bundle.main.js:21511
nNlU.e.exports @ bundle.main.js:21569
value @ bundle.main.js:20647
value @ bundle.main.js:20645
t @ bundle.main.js:22198
onready @ bundle.main.js:5742
(anonymous) @ bundle.main.js:12528
(anonymous) @ bundle.main.js:12619
push.LaBT.e.run @ async.node_modules.js:21233
push.LaBT.i.event @ async.node_modules.js:21187
push.LaBT.a.setScreenSize @ async.node_modules.js:25671
push.LaBT.a._changeCanvasSize @ async.node_modules.js:25644
e.run @ async.node_modules.js:23621
push.LaBT.n._update @ async.node_modules.js:23566
push.LaBT.a.render @ async.node_modules.js:25690
laya.display.Stage.render @ async.node_modules.js:28781
push.LaBT.a._loop @ async.node_modules.js:25679
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
s @ async.node_modules.js:22452
requestAnimationFrame (async)
wxRequestAnimationFrame @ gamePage.html:18
e @ async.node_modules.js:22453
push.LaBT.i.init @ async.node_modules.js:21160
push.cn1Y.Director.initStage @ async.node_modules.js:34902
initStage @ bundle.main.js:260
init @ bundle.main.js:5657
_execJump @ async.node_modules.js:52539
(anonymous) @ async.node_modules.js:52509
(anonymous) @ WAGame.js:4
(anonymous) @ WAGame.js:3
setTimeout (async)
setTimeout @ WAGame.js:3
_hashChangeHandler @ async.node_modules.js:52507
replaceTo @ async.node_modules.js:52592
jumpTo @ async.node_modules.js:52560
(anonymous) @ bundle.main.js:6443
onready @ bundle.main.js:24436
action @ bundle.main.js:22822
(anonymous) @ bundle.main.js:22833
Promise resolved (async)
success @ bundle.main.js:22832
(anonymous) @ WAGame.js:4
u @ WAGame.js:4
(anonymous) @ WAGame.js:4
s @ gamePage.html:1
invoke @ gamePage.html:1
r @ WAGame.js:4
c @ WAGame.js:4
u @ WAGame.js:9
(anonymous) @ WAGame.js:6
process @ bundle.main.js:22830
init @ bundle.main.js:24421
ERIh @ bundle.main.js:6442
webpack_require @ bundle.main.js:84
checkDeferredModules @ bundle.main.js:46
/CGf.Object.defineProperty.value @ bundle.main.js:221
(anonymous) @ bundle.main.js:224
require @ WAGame.js:3
(anonymous) @ WAGame.js:3
(anonymous) @ main.js? [sm]:4
require @ WAGame.js:3
(anonymous) @ WAGame.js:3
(anonymous) @ game.js? [sm]:3
require @ WAGame.js:3
(anonymous) @ gamePage.html:133
VM383:1 gameThirdScriptError
Function(...) is not a function;at api request success callback function
TypeError: Function(...) is not a function
at r (http://127.0.0.1:32203/game/js/dist/bundle.main.js:21424:30)
at i.get (http://127.0.0.1:32203/game/js/dist/bundle.main.js:20759:72)
at i.nNlU.i.resolve (http://127.0.0.1:32203/game/js/dist/bundle.main.js:20254:191)
at i.nNlU.i.setup (http://127.0.0.1:32203/game/js/dist/bundle.main.js:20809:37)
at i.nNlU.i.decode (http://127.0.0.1:32203/game/js/dist/bundle.main.js:20818:19)
at Object.load_viaProto (http://127.0.0.1:32203/game/js/dist/bundle.main.js:21516:21)
at XMLHttpRequest.nNlU.l.loadAssets.o.onloadend (http://127.0.0.1:32203/game/js/dist/bundle.main.js:21510:15)
at XMLHttpRequest._triggerEvent (http://127.0.0.1:32203/game/js/libs/weapp-adapter.js:1392:22)
at Function.success (http://127.0.0.1:32203/game/js/libs/weapp-adapter.js:1517:22)
at Object.success (http://127.0.0.1:32203/game/__dev__/WAGame.js:4:3592)

有没有vue版本

现在移动手机都支持vue.js,都不用dom操作,有vue版本嘛?

TypeError: Cannot read property 'length' of null at r.push

报错

  • 引用库svga.min.js,在许多手机里报些错误:TypeError: Cannot read property 'length' of null at r.push
    通过解压svga.min.js错误位置,可以定位到错误位置如下:

= p.input.length;
do {
if (0 === p.avail_out && (p.output = new a.Buf8(h), p.next_out = 0, p.avail_out = h), (n = o.inflate(p, u.Z_

报错的部分为加粗的部分

版本优化

针对分支 TypeScript-WebPack-Dev 问题收集优化记录

➜ 现存在问题

  • 开发构建工作流功能未完善
    • 开发 source map 是必须的,无需打包进去 build code
    • 浏览器自动自动刷新
  • 模块问题
    • 过量 Class 类封装,性能损耗,部分转为 function exec
  • 规范问题

➜ 建议优化后模块分块

image

为了扩展以后渲染引擎的扩展,唯一 entry 文件,根据动态 alias 打包 Player Render Engine 的模块引入。无需每次支持其他渲染引擎创建新的 entry。

➜ 其他优化

  • Source Code 异步处理
  • Promise 标准化,扩展支持 async / await
  • React / Vue.js 组件化
  • 不同 Player Engine 兼容同一套接口写法

setText style 传 family 无效

setText(textORMap, forKey) {
        let text = typeof textORMap === "string" ? textORMap : textORMap.text;
        let size = (typeof textORMap === "object" ? textORMap.size : "14px") || "14px";
        let family = (typeof textORMap === "object" ? textORMap.family : "") || "";
        let color = (typeof textORMap === "object" ? textORMap.color : "#000000") || "#000000";
        let offset = (typeof textORMap === "object" ? textORMap.offset : { x: 0.0, y: 0.0 }) || { x: 0.0, y: 0.0 };
        this._dynamicText[forKey] = {
            text,
            style: `${size} family`,
            color,
            offset,
        };
    }

上面代码的  style:`${size} faimly` 并没有把 family当成变量写进去
改成 style:family && family!=="" ? `${size} ${family}` : `${size} family`;

试过直接写成style:`${size} ${family}`, 当family不传的时候,style = “xxpx ”,多了个空格,这样会导致style设置失效,包括fontsize

iis 404.3

我的iis服务器有 a.svga这个文件,但是我用浏览器打开却无法找到 a.svga这个文件

功能建议:setImage增加对圆角的支持

使用setImage的时候,发现web版本无法像ios版本一样对图片设置圆角。希望能够新增border-radius这种功能的支持,谢谢~

CALayer *iconLayer = [CALayer layer];
iconLayer.cornerRadius = 84.0;
iconLayer.masksToBounds = YES;
iconLayer.borderWidth = 4.0;
iconLayer.borderColor = [UIColor colorWithRed:0xea/255.0 green:0xb3/255.0 blue:0x7d/255.0 alpha:1.0].CGColor;
[self.aPlayer setImage:iconImage forKey:@"99" referenceLayer:iconLayer];

画图之后的背景是黑色的,能否变成透明?

Attention

  • Do not ask any usage question, issue board is a issue board, accept library bugs only.
  • If you are facing any usage problem, read the README again.

Issue Template

Issue Description(What's your problem)

How To Reappear(How to reappear the issue)

Any Attachment(Provide a sample about your issue)

------ 中文分割线 ------

注意

  • 不要在 Issue 板块提问使用问题,Issue 板块只接受 Bug 反馈。
  • 如果遇到使用上的问题,仔细阅读 README。

Issue 模板

请尽量使用英文提交 Issue

请确切回答:问题的描述、重现方式、附件(提供一个 Demo 以重现问题)

web项目打包的时候会出现worker路径错误

开发目录

|——src
    |——js
    |   |——lib  svga.min.js
    |   |_____main.js  
    |——img
    |——css
    |——sass
    |——assest //xx.svga、worker
    |_____index.html

打包之后的目录

|——dist
    |——js
    |    |_____main.js  
    |——img
    |——css
    |——assest //xx.svga、worker
    |_____index.html

开发环境 main.js

 let parser = new Svga.Parser(`../assest/svga-worker.min.js`, Svga.DB);

开发之后路径会往上提一层 例如原本是a/b/assest/xxx 变成了a/assest/xxx

在react里获取失败是什么原因

在react里使用的时候,通过npm安装,按照步骤使用。但是获取到的parse是空对象是什么原因?
var parser = new SVGA.Parser('#demoCanvas');这句错误了,打印出来的获取到的parser是空对象,
var player = new SVGA.Player('#demoCanvas')这个可以正常获取得到,请问是什么原因?

ie9 no work

The browser below ie10 does not work. The open page in ie9 does not show. Loops in ie6,ie7 and ie8 does not work.
svga.zip

svga.ie.min.js文件bug

createSWFObject方法中,成功创建后没有回调,增加回调方法后,ie9以下浏览器运行时提示错误:SCRIPT438: 对象不支持“SVGAParser_Instance_load”属性或方法

startAnimationWithRange(),location 无效

startAnimationWithRange({location:0,length:20}) 跟 startAnimationWithRange(location:50,length:20)播放的片段是一样的,播放区间都是[0,20],
videoItem.frames 是 151

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.