Class: DisplayMode

Core. DisplayMode

Represents a Display Mode.

new DisplayMode(docViewer, mode [, scrollable])

Constructs a new Display Mode that specifies how the pages are displayed on the screen
Parameters:
Name Type Argument Description
docViewer Core.DocumentViewer The DocumentViewer instance
mode Core.DisplayModes A value from Core.DisplayModes identifying the display mode type
scrollable boolean <optional>
Whether the display mode is scrollable or not

Methods


getMode()

Returns the current display mode
Returns:
The current display mode value
Type
string

getPageOffset(pageNumber)

Returns the amount the page is offset from its container
Parameters:
Name Type Description
pageNumber number The number of the page
Returns:
A point with x and y properties of the amount the page is offset from its container
Type
Core.DisplayMode.Point

getPageTransform(pageNumber)

Returns the amount the page is shifted relative to the viewport
Parameters:
Name Type Description
pageNumber number The number of the page
Returns:
An object containing x, y offsets relative to the viewport and width, height of the page
Type
Core.DisplayMode.PageTransformReturnType

getSelectedPages(mousePt1, mousePt2)

Gets the indexes of the first and last pages selected
Parameters:
Name Type Description
mousePt1 Core.DisplayMode.Point The starting mouse point
mousePt2 Core.DisplayMode.Point The ending mouse point
Returns:
Object with first and last selected page numbers; last must be >= first
Type
Core.DisplayMode.SelectedPagesReturnType

getVisiblePages( [amountAhead] [, amountSide])

Returns an array of page indexes that are visible on screen
Parameters:
Name Type Argument Default Description
amountAhead number <optional>
0.5 The amount of space ahead of the viewport to count as visible as a multiple of the screen height
amountSide number <optional>
0.5 The amount of space to the side of the viewport to count as visible as a multiple of the screen height
Returns:
An array of visible page numbers ordered by percentage visible (most visible first)
Type
Array.<number>

isContinuous()

Returns whether the current display mode is continuous
Returns:
true if the display mode is continuous i.e. shows more than one row at a time
Type
boolean

IsScrollable()

Returns whether the current display mode is scrollable
Returns:
true if scrolling is enabled for this display mode
Type
boolean

pageToWindow(pagePt, pageNumber)

Converts page coordinates to window coordinates
Parameters:
Name Type Description
pagePt Core.DisplayMode.Point Point in page coordinates
pageNumber number The page number
Returns:
Point in window coordinates
Type
Core.DisplayMode.Point

pageToWindowNoRotate(pagePt, pageNumber)

Converts page coordinates to viewer coordinates without accounting for page rotation
Parameters:
Name Type Description
pagePt Core.DisplayMode.Point Point in unrotated page coordinates
pageNumber number The page number
Returns:
Point in viewer coordinates ignoring rotation
Type
Core.DisplayMode.Point

setCustomFunctions(fns)

Sets callbacks to provide custom functionality when in custom display mode
Parameters:
Name Type Description
fns Core.DisplayMode.CustomFunctionParameters Object containing callback overrides for the functions listed on Core.DisplayMode.CustomFunctionParameters

setParameters(nCols, nRows, currentRow, startRow, endRow)

Sets parameters of the display mode
Parameters:
Name Type Description
nCols number The number of columns
nRows number The number of rows
currentRow number The current row to be displayed
startRow number The starting row to have in the DOM
endRow number The ending row to have in the DOM
Deprecated:
  • setParameters has been deprecated

windowToPage(windowPt, pageNumber)

Converts window coordinates to page coordinates
Parameters:
Name Type Description
windowPt Core.DisplayMode.Point Point in window coordinates
pageNumber number The page number
Returns:
Point in page coordinates including the pageNumber property
Type
Core.DisplayMode.PagePoint

windowToPageNoRotate(windowPt, pageNumber)

Converts viewer coordinates to page coordinates without accounting for page rotation
Parameters:
Name Type Description
windowPt Core.DisplayMode.Point Point in viewer coordinates
pageNumber number The page number
Returns:
Point in unrotated page coordinates with pageNumber
Type
Core.DisplayMode.PagePoint

Type Definitions


CreatePageSectionsCallback()

Returns:
No return value
Type
void

CustomFunctionParameters

Type:
  • Object
Properties:
Name Type Argument Description
getPageTransform Core.DisplayMode.GetPageTransformCallback <optional>
Gets the amount the page is shifted relative to the viewport
getSelectedPages Core.DisplayMode.GetSelectedPagesCallback <optional>
Gets the indexes of the first and last pages selected
getVisiblePages Core.DisplayMode.GetVisiblePagesCallback <optional>
Gets the indexes of the currently visible pages
pageToWindow Core.DisplayMode.PageToWindowCallback <optional>
Converts page coordinates to window coordinates
windowToPage Core.DisplayMode.WindowToPageCallback <optional>
Converts window coordinates to page coordinates
createPageSections Core.DisplayMode.CreatePageSectionsCallback <optional>

GetPageTransformCallback(pageNumber)

Parameters:
Name Type Description
pageNumber number The page number
Returns:
Offsets and dimensions
Type
Core.DisplayMode.PageTransformReturnType

GetSelectedPagesCallback(mousePt1, mousePt2)

Parameters:
Name Type Description
mousePt1 Core.DisplayMode.Point Starting mouse point
mousePt2 Core.DisplayMode.Point Ending mouse point
Returns:
Selected page range
Type
Core.DisplayMode.SelectedPagesReturnType

GetVisiblePagesCallback( [amountAhead] [, amountSide])

Parameters:
Name Type Argument Description
amountAhead number <optional>
Vertical multiplier
amountSide number <optional>
Horizontal multiplier
Returns:
Visible page numbers ordered by visibility
Type
Array.<number>

PagePoint

Type:
  • Object
Properties:
Name Type Description
pageNumber number The page index
x number X coordinate in page coordinates
y number Y coordinate in page coordinates

PageToWindowCallback(pagePt, pageNumber)

Parameters:
Name Type Description
pagePt Core.DisplayMode.Point Point in page coordinates
pageNumber number The page number
Returns:
Point in window coordinates
Type
Core.DisplayMode.Point

PageTransformReturnType

Type:
  • Object
Properties:
Name Type Description
x number Horizontal offset of the page relative to the viewport (pixels)
y number Vertical offset of the page relative to the viewport (pixels)
width number Page width (pixels)
height number Page height (pixels)

Point

Type:
  • Object
Properties:
Name Type Description
x number The X coordinate
y number The Y coordinate

SelectedPagesReturnType

The selected page range
Type:
  • Object
Properties:
Name Type Description
first number First page in the range
last number Last page in the range

WindowToPageCallback(windowPt, pageNumber)

Parameters:
Name Type Description
windowPt Core.DisplayMode.Point Point in window coordinates
pageNumber number The page number
Returns:
Page-coordinate point including pageNumber
Type
Core.DisplayMode.PagePoint