Global

Members

__cachedLines :Array

Cached array of text wrapping.
Type:
  • Array
Source:

dynamicMinWidth :Number

Minimum calculated width of a textbox, in pixels. fixed to 2 so that an empty textbox cannot go to 0 and is still selectable without text.
Type:
  • Number
Default Value:
  • 2
Source:

lockScalingFlip

Override standard Object class values
Source:

minWidth :Number

Minimum width of textbox, in pixels.
Type:
  • Number
Default Value:
  • 20
Source:

noScaleCache

Override standard Object class values Textbox needs this on false
Source:

splitByGrapheme :Boolean

Use this boolean property in order to split strings that have no white space concept. this is a cheap way to help with chinese/japanese
Type:
  • Boolean
Since:
  • 2.6.0
Source:

type :String

Type of an object
Type:
  • String
Default Value:
  • textbox
Source:

Methods

_splitTextIntoLines(text) → {Array}

Gets lines of text to render in the Textbox. This function calculates text wrapping on the fly every time it is called.
Parameters:
Name Type Description
text String text to split
Source:
Returns:
Array of lines in the Textbox.
Type
Array

_wrapLine(line, lineIndex, desiredWidth, reservedSpace) → {Array}

Wraps a line of text using the width of the Textbox and a context.
Parameters:
Name Type Description
line Array The grapheme array that represent the line
lineIndex Number
desiredWidth Number width you want to wrap the line to
reservedSpace Number space to remove from wrapping for custom functionalities
Source:
Returns:
Array of line(s) into which the given text is wrapped to.
Type
Array

_wrapText(lines, desiredWidth) → {Array}

Wraps text using the 'width' property of Textbox. First this function splits text on newlines, so we preserve newlines entered by the user. Then it wraps each line using the width of the Textbox by calling _wrapLine().
Parameters:
Name Type Description
lines Array The string array of text that is split into lines
desiredWidth Number width you want to wrap to
Source:
Returns:
Array of lines
Type
Array

applyFilters(filters, forResizing) → {thisArg}

Applies filters assigned to this image (from "filters" array) or from filter param
Parameters:
Name Type Description
filters Array to be applied
forResizing Boolean specify if the filter operation is a resize operation
Source:
Returns:
return the fabric.Image object
Type
thisArg

cancelAll() → {Array.<AnimationContext>}

cancel all running animations at the next requestAnimFrame
Source:
Returns:
Type
Array.<AnimationContext>

cancelByCanvas(canvas) → {Array.<AnimationContext>}

cancel all running animations attached to canvas at the next requestAnimFrame
Parameters:
Name Type Description
canvas fabric.Canvas
Source:
Returns:
Type
Array.<AnimationContext>

cancelByTarget(target) → {Array.<AnimationContext>}

cancel all running animations for target at the next requestAnimFrame
Parameters:
Name Type Description
target *
Source:
Returns:
Type
Array.<AnimationContext>

copyGLTo2DDrawImage(sourceContext, targetCanvas, pipelineState)

Copy an input WebGL canvas on to an output 2D canvas. The WebGL canvas is assumed to be upside down, with the top-left pixel of the desired output image appearing in the bottom-left corner of the WebGL canvas.
Parameters:
Name Type Description
sourceContext WebGLRenderingContext The WebGL context to copy from.
targetCanvas HTMLCanvasElement The 2D target canvas to copy on to.
pipelineState Object The 2D target canvas to copy on to.
Source:

copyGLTo2DPutImageData(sourceContext, targetCanvas, pipelineState)

Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).
Parameters:
Name Type Description
sourceContext WebGLRenderingContext The WebGL context to copy from.
targetCanvas HTMLCanvasElement The 2D target canvas to copy on to.
pipelineState Object The 2D target canvas to copy on to.
Source:

findAnimation(cancelFunc) → {AnimationContext|undefined}

Parameters:
Name Type Description
cancelFunc CancelFunction the function returned by animate
Source:
Returns:
animation's options object
Type
AnimationContext | undefined

findAnimationIndex(cancelFunc) → {number}

Parameters:
Name Type Description
cancelFunc CancelFunction the function returned by animate
Source:
Returns:
Type
number

findAnimationsByTarget(target) → {Array.<AnimationContext>}

Parameters:
Name Type Description
target * the object that is assigned to the target property of the animation context
Source:
Returns:
array of animation options object associated with target
Type
Array.<AnimationContext>

isEmptyStyles(lineIndex) → {Boolean}

Returns true if object has no styling or no styling in a line
Parameters:
Name Type Description
lineIndex Number , lineIndex is on wrapped lines.
Source:
Returns:
Type
Boolean

isEndOfWrapping(lineIndex) → {Boolean}

Detect if the text line is ended with an hard break text and itext do not have wrapping, return false
Parameters:
Name Type Description
lineIndex Number text to split
Source:
Returns:
Type
Boolean

missingNewlineOffset()

Detect if a line has a linebreak and so we need to account for it when moving and counting style.
Source:
Returns:
Number

styleHas(lineIndex) → {Boolean}

Returns true if object has a style property or has it on a specified line
Parameters:
Name Type Description
lineIndex Number
Source:
Returns:
Type
Boolean

toObject(propertiesToIncludeopt) → {Object}

Returns object representation of an instance
Parameters:
Name Type Attributes Description
propertiesToInclude Array <optional>
Any properties that you might want to additionally include in the output
Source:
Returns:
object representation of an instance
Type
Object

toObject(propertiesToIncludeopt) → {Object}

Returns object representation of an instance
Parameters:
Name Type Attributes Description
propertiesToInclude Array <optional>
Any properties that you might want to additionally include in the output
Source:
Returns:
object representation of an instance
Type
Object

Type Definitions

AnimationCurrentState

Type:
  • Object
Properties:
Name Type Attributes Default Description
options.onChange function <optional>
Callback; invoked on every value change
options.onComplete function <optional>
Callback; invoked when value change is completed
options.startValue Number <optional>
0 Starting value
options.endValue Number <optional>
100 Ending value
options.byValue Number <optional>
100 Value to modify the property by
options.easing function <optional>
Easing function
options.duration Number <optional>
500 Duration of change (in ms)
options.abort function <optional>
Additional function with logic. If returns true, animation aborts.
currentValue number value in range [`startValue`, `endValue`]
completionRate number value in range [0, 1]
durationRate number value in range [0, 1]
Source: