Commit dd18c10382544e3c19bc5ad7bb568a5ec26ca2e6

Authored by Dang YoungWorld
1 parent b196bab487
Exists in master and in 1 other branch develop

fix delete

Showing 2 changed files with 20 additions and 16 deletions Side-by-side Diff

app/scripts/controllers/tshirtdesign.js
... ... @@ -63,6 +63,7 @@
63 63 //Custom control
64 64 fabric.Object.prototype.transparentCorners = true;
65 65 fabric.Object.prototype.hasRotatingPoint = false;
  66 + canvas.selection = false;
66 67  
67 68 var ctrVisible = {tl: false, ml:false, bl:false, mb: false, br: true, mr: false, tr: true, mt: true, mtr: false};
68 69 for(key in ctrVisible) {
... ... @@ -93,7 +94,7 @@
93 94 cursor: 'pointer',
94 95 action: function(e, target) {
95 96 fabric.Object.prototype.selectable = false;
96   - canvas.deactivateAll();
  97 + canvas.deactivateAll().renderAll();
97 98 delete currentObj;
98 99 $scope.designTextValue = '';
99 100 $timeout(function(){
100 101  
... ... @@ -256,8 +257,11 @@
256 257 }
257 258  
258 259 function onObjectOut() {
  260 + console.log('onObjectOut');
  261 + canvas.deactivateAll().renderAll();
259 262 delete currentObj;
260 263 $scope.designTextValue = '';
  264 + $scope.safeApply();
261 265 }
262 266  
263 267 function undoCanvas() {
264 268  
... ... @@ -505,10 +509,12 @@
505 509 }
506 510 };
507 511  
508   - $scope.focusInputText = function(text) {
  512 +
  513 + //Design text
  514 + $scope.inputText = function(e) {
509 515 currentObj = canvas.getActiveObject();
510 516 if(typeof currentObj == 'undefined' || currentObj == null) {
511   - $scope.iText = new fabric.IText('', {
  517 + var _iText = new fabric.IText('', {
512 518 left: 150,
513 519 top: 200,
514 520 fontFamily: typeof $scope.itemFont != 'undefined' ? $scope.listFontFamily[$scope.itemFont].slug : $scope.listFontFamily[0].slug,
... ... @@ -520,7 +526,7 @@
520 526 });
521 527 } else {
522 528 if(currentObj.type != 'i-text') {
523   - $scope.iText = new fabric.IText('', {
  529 + var _iText = new fabric.IText('', {
524 530 left: 150,
525 531 top: 200,
526 532 fontFamily: typeof $scope.itemFont != 'undefined' ? $scope.listFontFamily[$scope.itemFont].slug : $scope.listFontFamily[0].slug,
527 533  
528 534  
... ... @@ -531,20 +537,18 @@
531 537 editable: false
532 538 });
533 539 } else{
534   - $scope.iText = currentObj;
  540 + var _iText = currentObj;
535 541 }
536 542 }
537   - };
538 543  
539   - //Design text
540   - $scope.inputText = function(e) {
541   - if(typeof $scope.iText != "undefined") {
542   - var iText = $scope.iText;
543   - iText.text = e;
544   - canvas.add(iText);
545   - canvas.renderAll();
546   - canvas.setActiveObject(iText);
547   - }
  544 + _iText.set('text', e);
  545 + if(e.length > 1 && canvas.getActiveObject())
  546 + canvas.getActiveObject().remove();
  547 +
  548 + canvas.add(_iText);
  549 + canvas.setActiveObject(_iText);
  550 + canvas.renderAll();
  551 +
548 552 };
549 553 $scope.setFontFamily = function(font,index) {
550 554 $scope.itemFont = index;
app/views/design_part/text.html
... ... @@ -5,7 +5,7 @@
5 5 </div>
6 6 <div class="content clearfix">
7 7 <div>
8   - <input type="text" class="form-control" placeholder="ここに入力してください。" id="input-design-text" ng-focus="focusInputText(designText)" ng-change="inputText(designText)" ng-model="designText" ng-value="designTextValue">
  8 + <input type="text" class="form-control" placeholder="ここに入力してください。" id="input-design-text" ng-change="inputText(designText)" ng-model="designText" ng-value="designTextValue">
9 9 </div>
10 10 <div>
11 11 <ul class="font-family-box">