回答
我認爲文件在這方面有點過時。組沒有drawFunc,所以它們沒有寬度或高度。如果他們獲得寬度和高度,將可以創建剪輯組,這將是很好的。然而,就像現在這樣,組只是用來爲其中包含的對象定義一個相對的x和y起始座標。這使得可以立即移動多個對象(拖動,移動到,事件處理程序等),但這就是它。
var group = new Kinetic.Group({
x: 220,
y: 40,
draggable: true
});
只要讓您可拖動組和你的對象添加到組。
我可以在jsfiddle中添加代碼以便一次移動多個對象。主要會有一個組中的圖像和錨點 – user1531437
下面的代碼將允許您創建一個具有剪輯屬性的組。 將其實例化爲一個組,其中寬度和高度就是您的裁剪框。
Kinetic.Clipper = function(config) {
this._initGroup(config);
};
Kinetic.Clipper.prototype = {
_initGroup: function(config) {
this.nodeType = 'Group';
Kinetic.Container.call(this, config);
},
drawScene: function() {
if(this.isVisible()) {
var context = this.getLayer().getContext();
var width = this.getWidth(), height = this.getHeight();
context.save();
context.beginPath();
context.rect(0, 0, width, height);
context.clip();
var children = this.children, len = children.length;
for(var n = 0; n < len; n++) {
children[n].drawScene();
}
context.restore();
}
},
};
Kinetic.Global.extend(Kinetic.Clipper, Kinetic.Container);
你可以在jsFiddle中放入一個例子嗎? – user1531437
特別是一個例子,其中組不在(0,0),我無法工作。 –
文檔已過時或錯誤。 不可能直接改變組大小
- 1. KineticJS fillPatternImage從版本5.0起不起作用
- 2. KineticJS dragBoundFunc不工作
- 3. Kineticjs fillAlpha不工作
- 4. kineticjs鉻填不工作
- 5. Kinetic.Image config cornerRadius不起作用
- 6. 填充,邊界對kineticjs不起作用鉻上的文本對象
- 7. 不能與KineticJS
- 8. KineticJS Mouseover不能正常工作
- 9. KineticJS和HTML5 - 拖動不工作
- 10. 不起作用
- 11. 不起作用?
- 12. 不起作用?
- 13. 不起作用?
- 14. KineticJS&IE9
- 15. selenium.captureEntirePageScreenshot不起作用,但selenium.captureScreenshot起作用
- 16. ON_CALL不起作用,但EXPECT_CALL起作用
- 17. kineticjs - mouseover不準確
- 18. 副作用不起作用
- 19. KineticJS - 作物填充圖像
- 20. 如何用kineticjs製作橡皮
- 21. Document.querySelectorAll()不起作用
- 22. chart.interactiveLayer.tooltip.chartContainer不起作用?
- 23. dumpTreshold不起作用
- 24. ActionListener不起作用
- 25. suspendEvents不起作用
- 26. mysql_rollback()不起作用
- 27. RequestRouteToHost不起作用
- 28. spring.mvc.view.suffix不起作用
- 29. BluetoothLEAdvertisementWatcher不起作用
- 30. setText(「」)不起作用
你可以把你的示例代碼放在jsfiddle中嗎? –
任何人都可以請幫助嗎? – user1531437