我是angular 5和FabricJS的新手。我上课时得到了对象 var audioSession = AVAudioSession.sharedInstance();
try {
audioSession.setCategoryError(AVAudioSessionCategoryAmbient);
audioSession.setActiveError(true);
} catch(err) {
console.log("setting audioSession category failed");
}
和方法vrchol
。我想将事件添加到changeColor
,但这不起作用。
vrchol
this.vrchol.on("mouseover",this.changeColor);
答案 0 :(得分:0)
在mouseover
事件中,将cachedirty设置为true并呈现对象,以便其反映更改。
演示
var canvas = new fabric.Canvas('c');
var circle = new fabric.Circle({
radius: 100
});
canvas.add(circle);
circle.on('mouseover', onMouseOver);
circle.on('mouseout', onMouseOut);
function onMouseOver() {
if (this.fill != 'red') {
this.set({
'fill': 'red',
'dirty': true
});
canvas.requestRenderAll();
}
}
function onMouseOut() {
if (this.fill == 'red') {
this.set({
'fill': 'black',
'dirty': true
});
canvas.requestRenderAll();
}
}
canvas{
border:1px solid;
}
<script src="http://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.6.0/fabric.js"></script>
<canvas id='c' width=400 height=400></canvas>