Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SVG&;JavaScript-动画SVG文件对象不工作?_Javascript_Html_Css_Svg - Fatal编程技术网

SVG&;JavaScript-动画SVG文件对象不工作?

SVG&;JavaScript-动画SVG文件对象不工作?,javascript,html,css,svg,Javascript,Html,Css,Svg,所以我有一个SVG文件。如果你去这个网站,它应该给它设置动画,但是它没有。它在localhost中工作。有人能帮我吗?我想这里已经发了一些帖子,但是没有人回复,所以我想我会发一个新的:) SVG文件: 用于旋转的JavaScript: var wheelSVG = $(); var spinner = $(); $("object").load(function() { wheelSVG = $("object").contents().find("svg"); spinner

所以我有一个SVG文件。如果你去这个网站,它应该给它设置动画,但是它没有。它在localhost中工作。有人能帮我吗?我想这里已经发了一些帖子,但是没有人回复,所以我想我会发一个新的:)

SVG文件:

用于旋转的JavaScript:

var wheelSVG = $();
var spinner = $();
$("object").load(function() {
    wheelSVG = $("object").contents().find("svg");
    spinner = spinner.add(wheelSVG.find("#spin"));
    center = wheelSVG.find("#ui ellipse");
    centerText = wheelSVG.find("#number");
    clearInterval(beforeLoginSpinInterval);
    if (!loggedinn) {
        beforeLoginSpinInterval = setInterval(function() {
            currentRotation += 0.25;
            spinner.css("transform", 'rotate(' + currentRotation + 'deg)');
        }, 20);
    }
});
setTimeout(function() {
            wheelSVG = $("object").contents().find("svg");
            spinner = spinner.add(wheelSVG.find("#spin"));
            center = wheelSVG.find("#ui ellipse");
            centerText = wheelSVG.find("#number");
            clearInterval(beforeLoginSpinInterval);
            if (!loggedinn) {
                beforeLoginSpinInterval = setInterval(function() {
                    currentRotation += 0.25;
                    spinner.css("transform", 'rotate(' + currentRotation + 'deg)');
                }, 10);
            }

我通过修正一些错误使它工作起来

我必须定义这些未定义的变量:

var currentRotation = 0;
var beforeLoginSpinInterval;
var loggedinn;
您的
setTimeout
缺少一个右括号,所以我修复了这个问题

这条线坏了:

wheelSVG = $("object").contents().find("svg");
所以我把它概括为:

wheelSVG = $("svg");

演示


我通过修复一些错误使它工作起来

我必须定义这些未定义的变量:

var currentRotation = 0;
var beforeLoginSpinInterval;
var loggedinn;
您的
setTimeout
缺少一个右括号,所以我修复了这个问题

这条线坏了:

wheelSVG = $("object").contents().find("svg");
所以我把它概括为:

wheelSVG = $("svg");

演示


请创建一个,这样我们就可以在不做大量工作的情况下看到正在发生的事情。请创建一个,这样我们就可以在不做大量工作的情况下看到正在发生的事情。我会尝试。谢谢,顺便说一句。你能看到JavaScript错误吗?我在Codepen中运行代码时,使用Chrome开发者工具控制台看到了JavaScript错误。嗯:(,很遗憾,我无法在网站上运行它:(如果你发送一个链接到你的网站,我会在那里看看。但是我启用了所有svg类型等:/我会试试。谢谢,顺便说一句。你能看到JavaScript错误吗?我在Codepen中运行代码时,使用Chrome开发者工具控制台看到了JavaScript错误。嗯:(,很遗憾,我无法在网站上运行它:(如果您向您的网站发送链接,我将在那里查看。但我启用了所有svg类型等:/