Я пытался использовать: < /p>
Код: Выделить всё
e.evt.preventDefault();
e.evt.stopPropagation();
e.cancelBubble = true;
< /code>
Но это не работает. < /p>
const width = 400;
const height = 300;
const stage = new Konva.Stage({
container: '.static-canvas',
width: width,
height: height
});
const layer = new Konva.Layer();
const pentagon = new Konva.RegularPolygon({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
sides: 5,
radius: 70,
fill: 'red',
stroke: 'black',
strokeWidth: 4
});
layer.add(pentagon);
stage.add(layer);
pentagon.on( 'click', (e) => {
e.evt.preventDefault();
e.evt.stopPropagation();
e.cancelBubble = true;
console.log( 'click' )
});
pentagon.on( 'contextmenu', (e) => {
e.evt.preventDefault();
e.evt.stopPropagation();
e.cancelBubble = true;
console.log( 'contextclick' );
});< /code>
body {
margin: 0;
padding: 0;
background-color: #F0F0F0;
}
.canvas {
float: left;
width: 50%;
}
.static-canvas {
.konvajs-content {
background: orange;
}
}< /code>
Подробнее здесь: https://stackoverflow.com/questions/796 ... menu-click
Мобильная версия