我的网站包含大量广告,这些广告需要一段时间才能加载.这不是一个问题,但我注意到任何SVG动画都会立即绘制第一帧,但动画只有在页面上完成所有加载后才会出现.SVG动画通常表示一个微调器/加载图标.有没有一种方法可以立即启动SVG动画?或者,如果我将其转换为纯CSS,它会立即生成动画吗?
这是我的svg加载程序代码:http: //jsfiddle.net/5zq5j4d9/
<div class="loading-icon-outer">
<div class="loading-icon">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" style="enable-background:new 0 0 50 50;" xml:space="preserve">
<rect x="0" y="8" width="4" height="4" fill="#333" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; 0.2" begin="0s" dur="0.6s" repeatCount="indefinite" />
<animate attributeName="height" attributeType="XML" values="4; 20; 4" begin="0s" dur="0.6s" repeatCount="indefinite" />
<animate attributeName="y" attributeType="XML" values="8; 0; 8" begin="0s" dur="0.6s" repeatCount="indefinite" />
</rect>
<rect x="8" y="8" width="4" height="4" fill="#333" opacity="0.2">
<animate attributeName="opacity" attributeType="XML" values="0.2; 1; 0.2" begin="0.15s" dur="0.6s" …Run Code Online (Sandbox Code Playgroud) I've used the following css in various places on my site:
http://jsfiddle.net/uycq29mt/1/
.a {
position:absolute;
background:red;
width:600px;
height:100px;
left:50%;
transform: translate(-50%);
}
Run Code Online (Sandbox Code Playgroud)
在Internet Explorer中运行时,您会注意到一个水平滚动条似乎忽略了有关页面总宽度的转换.
我有一堆用LZMA压缩的SWF文件,我想在我的服务器上以编程方式解压缩和读取PHP.有人可以指导我使用PHP LZMA SDK吗?我已经用Google搜索了,但到目前为止还没有发现任何东西,只是引用了一个断开的链接(7z扩展为php?)
我有一个工作的python模块,设法读取LZMA压缩SWF的标头,但它需要一个名为pyLZMA的模块,它似乎不想在我的服务器上安装,并让它在本地工作是一个巨大的痛苦,所以我如果有的话,我更喜欢PHP解决方案.
我的网站包含大量广告,加载需要一段时间。确切地说,这并不是一个问题,但我注意到任何 SVG 动画都会立即绘制第一帧,但动画只有在页面上的所有加载完成后才会出现。SVG 动画通常指示旋转器/加载图标。如果它在加载它所代表的元素之前不进行动画处理,那么它实际上没有任何作用。
有没有办法提前开始动画?
如果我从XAMPP上的本地服务器加载此脚本的chrome:
header("Content-Type:text/plain");
set_time_limit(0);
$max = 40;
for ($i = 0; $i < $max; $i++) {
$response = array( 'server time: ' . date("h:i:s", time()), 'progress' => round($i/$max*100));
echo json_encode($response);
ob_flush();
flush();
sleep(1);
}
ob_clean();
Run Code Online (Sandbox Code Playgroud)
它按预期工作,每秒页面显示一个新的响应.但是,当我将其上传到我的远程服务器(运行相同版本的php)时,它会等到整个脚本完成后再显示输出.在非常长的脚本上,它每30-60秒左右更新一次输出.
正如标题所示,我尝试使用所有不同的刷新功能,但没有任何作用.我的本地服务器和远程服务器的php.ini可能有些不同,但我不知道是什么.
请帮忙.
- -编辑 - -
我一直在做更多的测试.我注意到它确实只更新每4096个字节,这恰好是我的远程服务器的'output_buffering'的php ini值.但是,出于某种原因,如果我将output_buffering更改为"1"或"关闭",则不会发生任何变化.它仍然只更新每4096个字节.
我正在同一浏览器上的不同服务器上测试2个相同的脚本.
import sys
import os
import zlib
try:
import pylzma as lzma
except ImportError:
import lzma
from io import StringIO
import struct
#-----------------------------------------------------------------------------------------------------------------------
def read_ui8(c):
return struct.unpack('<B', c)[0]
def read_ui16(c):
return struct.unpack('<H', c)[0]
def read_ui32(c):
return struct.unpack('<I', c)[0]
def parse(input):
"""Parses the header information from an SWF file."""
if hasattr(input, 'read'):
input.seek(0)
else:
input = open(input, 'rb')
header = { }
# Read the 3-byte signature field
header['signature'] = signature = b''.join(struct.unpack('<3c', input.read(3))).decode()
# Version
header['version'] = read_ui8(input.read(1))
# File size …Run Code Online (Sandbox Code Playgroud) 我希望异步函数以每秒一次的最大速率运行。
async function update(){
await wait_for_response();
}
setInterval(update, 1000);
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,如果函数花费的时间超过一秒钟,则下一次更新将在上一次完成之前开始。
如果update()花费的时间超过1秒,则我希望下一个更新要等到最后一个更新完成后才立即运行。
是否有一个简单的内置方法或标准实践来实现?
animation ×2
compression ×2
css ×2
jquery ×2
lzma ×2
php ×2
svg ×2
ads ×1
flush ×1
html ×1
javascript ×1
long-polling ×1
node.js ×1
python ×1