如何将鼠标悬停或任何事件绑定到画布上的绘制对象?例如,我试过这个:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
//STEP ONE
var stepOneRec = ctx.rect(20, 60, 266, 50);
ctx.stroke();
stepOneRec.addEventListener("mouseover", function() { alert('it works!'); });
Run Code Online (Sandbox Code Playgroud)
在一个网站上,我看到它显示了一个使用Kinetic.js的方法.如果这是唯一的方法,我将使用它,我只是假设有一种方法将事件绑定到绘制的元素而无需额外的插件.抱歉Canvas noob.我在这里用我的代码做了一个小提琴:http: //jsfiddle.net/jyBSZ/2/
好像我在文档中做了所有事情并引用了其他示例.
尝试为文本组件旋转设置动画:
this.state = {
rotateAnimation: new Animated.Value(0),
};
spin = () => {
this.state.rotateAnimation.setValue(0);
Animated.timing(this.state.rotateAnimation, {
toValue: 1,
duration: 3000,
easing: Easing.linear
}).start((animation) => {
if (animation.finished) {
this.spin();
}
});
};
render() {
return (
<Content>
<View>
<Text style={{
transform: [
{
rotate:
this.state.rotateAnimation.interpolate({
inputRange: [0, 1],
outputRange: ["0deg", "360deg"]
})
}
]
} ]}>{this.FAIcons.circleONotch}</Text>
</View>
</Content>
);
}
Run Code Online (Sandbox Code Playgroud)
如果我手动输入任何程度,即工作正常 rotate: "90deg"
但是,当我使用interpolate()时,我收到此错误: Transform with key of "rotate" must be a string: {"rotate":"0deg"}
似乎Interpolate没有返回一个字符串.我尝试使用"toString()"对其进行类型转换,但后来我收到此错误:Rotate transform must be …
这是我的jQuery
$('#samsungShine').mouseover(function () {
$('#samsungShineImage').animate({
"margin-left": "304px"
}, 700);
}).mouseout(function () {
$('#samsungShineImage').css("margin-left", "-304px");
});
Run Code Online (Sandbox Code Playgroud)
当我鼠标移动时,它工作得非常好,当我鼠标移除时,它没有重置,它重新播放鼠标悬停...这里是问题的小提示,所以你可以看到我的意思:
我收到此错误:
调用非对象上的成员函数 addChild()
但 XML 文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<urlset>
<url>
<loc>http://mysite.com/</loc>
<changefreq>weekly</changefreq>
<priority>1.00</priority>
</url>
</urlset>
Run Code Online (Sandbox Code Playgroud)
我正在这样做:
//APPEND TO SITEMAP
$file = '../sitemap.xml';
$xml = simplexml_load_file($file);
$urlset = $xml->urlset;
$urls = $urlset->addChild('url');
$urls->addAttribute("mongoID", $theAuthorUniqueMongoID);
$urls->addChild('loc', 'http://mysite.com/author/'.$authorLink.'/');
$urls->addChild('changefreq', 'monthly');
$urls->addChild('priority', '0.80');
$xml->asXML($file);
Run Code Online (Sandbox Code Playgroud)
我基本上只是在我的站点地图上添加一些内容。我从来都不擅长 XML,但我不确定我在这方面做错了什么。