WidgetPosition Class
Calculates the position where an Widget should be displayed based on the point where user interacted with the editor.
Index
Methods
Properties
Methods
_animate
-
callback
Requests an animation frame, if possible, to simulate an animation.
Parameters:
-
callback
FunctionThe function to be executed on the scheduled frame.
_getXPoint
-
selectionData
-
eventX
Returns the position of the Widget.
Parameters:
-
selectionData
ObjectThe data about the selection in the editor as returned from getSelectionData
-
eventX
ObjectThe X coordinate received from the native event (mouseup).
Returns:
The calculated X point in page coordinates.
_getYPoint
-
selectionData
-
nativeEvent
Returns the position of the Widget.
Parameters:
-
selectionData
ObjectThe data about the selection in the editor as returned from getSelectionData
-
nativeEvent
ObjectThe data about event is fired
Returns:
The calculated Y point in page coordinates.
cancelAnimation
()
Cancels an scheduled animation frame.
getConstrainedPosition
-
attrs
-
viewPaneSize
Returns an object which contains the position of the element in page coordinates, restricted to fit to given viewport.
Parameters:
-
attrs
ObjectThe following properties, provided as numbers:
- height
- left
- top
- width
-
viewPaneSize
ObjectOptional. If not provided, the current viewport will be used. Should contain at least these properties:
- width
Returns:
An object with x
and y
properties, which represent the constrained position of the
element.
getDefaultProps
()
Lifecycle. Returns the default values of the properties used in the widget.
getInteractionPoint
()
Object
Returns the position, in page coordinates, according to which a widget should appear. Depending on the direction of the selection, the wdiget may appear above of or on bottom of the selection.
It depends on the props editorEvent to analyze the following user-interaction parameters:
- {Object} selectionData The data about the selection in the editor as returned from getSelectionData
- {Number} pos Contains the coordinates of the position, considered as most appropriate. This may be the point where the user released the mouse, or just the beginning or the end of the selection.
Returns:
An Object which contains the following properties: direction, x, y, where x and y are in page coordinates and direction can be one of these: CKEDITOR.SELECTION_BOTTOM_TO_TOP or CKEDITOR.SELECTION_TOP_TO_BOTTOM
getWidgetXYPoint
-
left
-
top
-
direction
Returns the position of the Widget taking in consideration the WidgetPosition/gutter:attribute attribute.
Parameters:
-
left
NumberThe left offset in page coordinates where Toolbar should be shown.
-
top
NumberThe top offset in page coordinates where Toolbar should be shown.
-
direction
NumberThe direction of the selection. May be one of the following: CKEDITOR.SELECTION_BOTTOM_TO_TOP or CKEDITOR.SELECTION_TOP_TO_BOTTOM
Returns:
An Array with left and top offsets in page coordinates.
isVisible
()
Boolean
Returns true if the widget is visible, false otherwise
Returns:
True if the widget is visible, false otherwise
moveToPoint
-
startPoint
-
endPoint
Moves a widget from a starting point to a destination point.
Parameters:
-
startPoint
ObjectThe starting point for the movement.
-
endPoint
ObjectThe destination point for the movement.
show
()
Shows the widget with the default animation transition.
updatePosition
()
Updates the widget position based on the current interaction point.
Properties
constrainToViewport
Boolean
Should the widget to be restricted to the viewport, or not.
Default: true
editorEvent
SyntheticEvent
The provided editor event.
gutter
Object
The gutter (vertical and horizontal) between the interaction point and where the widget should be rendered.
Default: { left: 0, top: 10 }