1
我必須在我的應用程序內更改我的fabric.js
畫布大小。在我有這個定義我controller.js
:angular.js - 設置陣列的寬度和高度farbricjs畫布
kitchensink.controller('CanvasControls', function ($scope) {
$scope.canvas = canvas;
$scope.getActiveStyle = getActiveStyle;
addAccessors($scope);
watchCanvas($scope);
// Editing Canvas Size
// ================================================================
$scope.setCanvasSize = function() {
console.log('Resizing now...');
canvas.setWidth(presetSizes.width);
canvas.setHeight(presetSizes.height);
canvas.calcOffset();
};
$scope.presetSizes = [
{
name: 'iPad Landscape',
height: 768,
width: 1024
},
{
name: 'iPad Portrait',
height: 1024,
width: 766
},
{
name: 'iPad Pro Landscape',
height: 1024,
width: 1366
},
{
name: 'iPad Pro Portrait',
height: 1366,
width: 1024
}
];
})
我想設置我的畫布大小在我的index.html與NG-點擊這樣的:
<x-menu>
<x-menuitem value="no_bg" ng-click='setCanvasSize(size.width, size.height)' ng-repeat='size in presetSizes' selected="true">
<x-label>{{ size.name }}</x-label>
</x-menuitem>
</x-menu>
我收到陣列{{ size.name }}
但我明明做錯事的設置/獲取寬度和高度...
非常感謝您的Jordy!像一個迷人的工作。我看到我有多少學習:-) –
@SandorRozsa歡迎您 –