[Vuejs]-Is there a way to increase and decrease font-size in fabricjs onclick

0👍

Got it

     $('.qtyplus').click(function(e){
        // Stop acting like a button
        e.preventDefault();
        // Get the field name

        // Get its current value
        currentVal = parseInt($('input[name=quantity]').val());
        // If is not undefined
        if (!isNaN(currentVal)) {
          // Increment
          $('input[name=quantity]').val(currentVal + 1);

          if(currentVal!='')
          {
            var activeObj = canvas.getActiveObject();
            //Check that text is selected
            if(activeObj==undefined)
            {
              alert('Please select a Text');
              return false;
            }
            activeObj.set({
              scaleX:1,
              scaleY:1,
              fontSize: currentVal
            });
            canvas.renderAll();
          }

        } else {
          // Otherwise put a 0 there
          $('input[name=quantity]').val(0);
        }
      });
      // This button will decrement the value till 0
      $(".qtyminus").click(function(e) {
        // Stop acting like a button
        e.preventDefault();
        // Get the field name

        // Get its current value
        currentVal = parseInt($('input[name=quantity]').val());
        // If it isn't undefined or its greater than 0
        if (!isNaN(currentVal) && currentVal > 0) {
          // Decrement one
          $('input[name=quantity]').val(currentVal - 1);

          if(currentVal!='')
          {
            var activeObj = canvas.getActiveObject();
            //Check that text is selected
            if(activeObj==undefined)
            {
              alert('Please select a Text');
              return false;
            }
            activeObj.set({
              scaleX:1,
              scaleY:1,
              fontSize: currentVal
            });
            canvas.renderAll();
          }

        } else {
          // Otherwise put a 0 there
          $('input[name=quantity]').val(0);
        }
      });

Leave a comment