Skip to content

Commit

Permalink
New: Documentation for viewer methods (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored Aug 8, 2017
1 parent 4d97d99 commit 48f681d
Show file tree
Hide file tree
Showing 10 changed files with 181 additions and 14 deletions.
Binary file added images/multi-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/lib/viewers/box3d/image360/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The 360 image viewer renders a preview of an image stored as an equirectangular
This viewer gives you an interactive view of a 360 degree image. First, a low resolution version of the image is loaded to give a quick view before the full resolution image is finished loading. Clicking and dragging with the left mouse button will change the view direction (single touch and drag on touch-enabled device).

### Controls:

* Fullscreen (can be exited with the escape key)
* VR Button: When using a browser that supports WebVR and a suitable VR device is attached to your computer, a VR button will be available to allow toggling in and out of VR mode.

Expand All @@ -23,6 +24,7 @@ Currently, this previewer requires that the file be named with a '.360' precedin
`'360.jpg', '360.jpeg', '360.png'`

## Events

The 360 image viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -33,3 +35,9 @@ The 360 image viewer fires the following events
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads ||
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |

## Methods

The following methods are available for the 360 image viewer.
| Method Name | Explanation | Method Parameters |
| toggleFullscreen | Toggles fullscreen mode ||
11 changes: 11 additions & 0 deletions src/lib/viewers/box3d/model3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Preview gives users the ability to view a single file within Box so, by default,
`box3d, fbx, dae, 3ds, obj, stl, ply`

## Events

The Model3D viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -45,3 +46,13 @@ The Model3D viewer fires the following events
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads ||
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |

## Methods

The following methods are available for the model3D viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| setModelScale | Sets the scale used to render the model | {number} the size of the largest dimension of the model in meters|
| setModelAlignment | Set the position of the model relative a point and the model's bounding box | {vector} position, {vector} alignment vector |
| toggleFullscreen | Toggles fullscreen mode ||
37 changes: 23 additions & 14 deletions src/lib/viewers/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The document viewer remembers which page you were viewing upon closing the previ
| annotations | boolean | Optional. Whether annotations on content are shown. Defaults to false |

## Events

The document viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -46,19 +47,36 @@ The document viewer fires the following events
| printsuccess | An attempt to print triggered successfully ||
| printsuccess | An attempt to print failed ||

## Methods

The following methods are available for the document viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| print | Prints the file as a PDF blob ||
| previousPage | Navigates to the previous page ||
| nextPage | Navigates to the next page ||
| setPage | Navigates to a given page | {number} page number |
| getCachedPage | Gets the last cached page number ||
| cachePage | Caches the current page number | {number} page number |
| zoomIn | Zooms the document in | {number} number of steps to zoom in based on scale |
| zoomOut | Zooms the document out | {number} number of steps to zoom out based on scale |
| toggleFullscreen | Toggles fullscreen mode ||

# Presentation Viewer

The presentation viewer renders previews of powerpoint files.

## Screenshot

![Screenshot of presentation viewer](../../../../images/presentation.png)

## Behavior

The presentation viewer remembers which slide you were viewing upon closing the preview. The next time that file is opened, you will immediately be brought to that page. Scrolling the mouse up and down, or swiping up and down on mobile will transition between slides. Zooming in or out will increase or decrease the size of the slide respectively. If the zoom level causes the content to overflow, scrolling the mouse will allow you to scroll around the slide. To return to normal scrolling behavior, the user must zoom out until the overflow is removed.

### Controls:

* Zoom In
* Zoom Out
* Set Page: either with the up and down arrows, or by clicking the page number and entering text
Expand All @@ -75,18 +93,9 @@ The presentation viewer remembers which slide you were viewing upon closing the
| annotations | boolean | Optional. Whether annotations on content are shown. Defaults to false |

## Events
The presentation viewer fires the following events

| Event Name | Explanation | Event Data |
| --- | --- | --- |
| destroy | The preview is intentionally destroyed ||
| load | The preview loads | 1. {string} **error** (optional): error message 2. {object} **file**: current file 3. {object} **metrics**: information from the logger 4. {object} **viewer**: current viewer |
| notification | A notification is displayed ||
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads ||
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
| zoom | The preview zooms in or out | 1. {number} **zoom**: new zoom value 2. {boolean} **canZoomIn**: true if the viewer can zoom in more 3. {boolean} **canZoomOut**: true if the viewer can zoom out more |
| pagerendered | A page renders | {number} page number of rendered page |
| pagefocus | A page is visible | {number} page number of focused page |
| scrollstart | The viewer starts to scroll | 1. {number} **scrollTop**: number of pixels scrolled from top of viewport 2. {number} **scrollLeft**: number of pixels scrolled from left of viewport |
| scrollend | The viewer stops scrolling | 1. {number} **scrollTop**: number of pixels scrolled from top of viewport 2. {number} **scrollLeft**: number of pixels scrolled from left of viewport |
See document viewer events.

## Methods

See document viewer methods.
1 change: 1 addition & 0 deletions src/lib/viewers/iframe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Both Box Notes and Box DICOM have full-featured viewers within the main Box Web
`boxnote, boxdicom`

## Events

The iframe viewer fires the following events

| Event Name | Explanation | Event Data |
Expand Down
58 changes: 58 additions & 0 deletions src/lib/viewers/image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,61 @@ The image viewer fires the following events
| panend | Panning ends ||
| rotate | The image rotates ||
| printsuccess | An attempt to print triggered successfully ||

## Methods

The following methods are available for the image viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| zoom | Zooms the image | {string} 'in', 'out', or 'reset' |
| print | Prints the image ||
| rotateLeft | Rotates the image counter-clockwise by 90 degrees ||
| isRotated | Determines if the image has been rotated 90 or 270 degrees ||
| toggleFullscreen | Toggles fullscreen mode ||

# Multi-Page Image Viewer

The multi-page image viewer renders previews of multi page image files.

## Screenshot
![Screenshot of multi-page image viewer](../../../../images/multi-page.png)

## Behavior
At the default zoom level, clicking on the image will zoom in once. When zoomed in, clicking on the document will return to the default zoom level. When zoomed out, clicking on the document will zoom in until the original zoom level is reached.

### Controls:
* Zoom In
* Zoom Out
* Fullscreen: can be exited with the escape key

## Supported File Extensions

`tif, tiff`

## Events
The image viewer fires the following events

| Event Name | Explanation | Event Data |
| --- | --- | --- |
| destroy | The preview is intentionally destroyed ||
| load | The preview loads | 1. {string} **error** (optional): error message 2. {object} **file**: current file 3. {object} **metrics**: information from the logger 4. {object} **viewer**: current viewer |
| notification | A notification is displayed ||
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads ||
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
| zoom | The preview zooms in or out | 1. {number} **zoom**: new zoom value 2. {boolean} **canZoomIn**: true if the viewer can zoom in more 3. {boolean} **canZoomOut**: true if the viewer can zoom out more |
| pan | The preview is panning ||
| panstart | Panning starts ||
| panend | Panning ends ||
| printsuccess | An attempt to print triggered successfully ||

## Methods

The following methods are available for the multi-page image viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| zoom | Zooms the image | {string} 'in', 'out', or 'reset' |
| print | Prints the image ||
| toggleFullscreen | Toggles fullscreen mode ||
35 changes: 35 additions & 0 deletions src/lib/viewers/media/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The DASH viewer uses a black background to create a more native viewing experien
`3g2, 3gp, avi, m2v, m2ts, m4v, mkv, mov, mp4, mpeg, mpg, ogg, mts, qt, wmv`

## Events

The DASH viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -48,6 +49,21 @@ The DASH viewer fires the following events
| pause | The video pauses ||
| seeked | The video skips to a time | {number} time |

## Methods

The following methods are available for the DASH viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| setMediaTime | Updates the media element's time | {number} time in seconds |
| setVolume | Updates the media element's volume | {number} value between 0 and 1
| togglePlay | Toggles playback ||
| toggleMute | Toggles between mute and current volume value ||
| quickSeek | Seeks forward/backward from current point | {number} increment in seconds ||
| increaseVolume | Increases volume by a small increment ||
| decreaseVolume | Decreases volume by a small increment ||
| toggleFullscreen | Toggles fullscreen mode ||


# MP3 Viewer

Expand Down Expand Up @@ -90,6 +106,20 @@ The MP3 viewer fires the following events
| pause | The audio pauses ||
| seeked | The audio skips to a time | {number} time |

## Methods

The following methods are available for the MP3 viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| setMediaTime | Updates the media element's time | {number} time in seconds |
| setVolume | Updates the media element's volume | {number} value between 0 and 1
| togglePlay | Toggles playback ||
| toggleMute | Toggles between mute and current volume value ||
| quickSeek | Seeks forward/backward from current point | {number} increment in seconds ||
| increaseVolume | Increases volume by a small increment ||
| decreaseVolume | Decreases volume by a small increment ||


# MP4 Viewer

Expand Down Expand Up @@ -119,6 +149,7 @@ The mp4 viewer uses a black background to create a better viewing experience. Vo
`3g2, 3gp, avi, m2v, m2ts, m4v, mkv, mov, mp4, mpeg, mpg, ogg, mts, qt, wmv`

## Events

The MP4 viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -134,3 +165,7 @@ The MP4 viewer fires the following events
| play | The video plays ||
| pause | The video pauses ||
| seeked | The video skips to a time | {number} time |

## Methods

See DASH viewer methods
9 changes: 9 additions & 0 deletions src/lib/viewers/office/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ There are several limitations at the moment:
`xlsx`

## Events

The Office viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -30,3 +31,11 @@ The Office viewer fires the following events
| navigate | The preview is shown for a given index | {object} file |
| reload | The preview reloads ||
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |

## Methods

The following methods are available for the office viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| print | Prints the image ||
1 change: 1 addition & 0 deletions src/lib/viewers/swf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Note that all network requests made by the flash content will be blocked due to
`swf`

## Events

The SWF viewer fires the following events

| Event Name | Explanation | Event Data |
Expand Down
35 changes: 35 additions & 0 deletions src/lib/viewers/text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This viewer does not support printing.
`csv, tsv`

## Events

The CSV viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -35,6 +36,17 @@ The CSV viewer fires the following events
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
| zoom | The preview zooms in or out | 1. {number} **zoom**: new zoom value 2. {boolean} **canZoomIn**: true if the viewer can zoom in more 3. {boolean} **canZoomOut**: true if the viewer can zoom out more |

## Methods

The following methods are available for the CSV viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| zoom | Zooms in or out based on the given value | {string} 'in' or 'out' |
| zoomIn | Zooms in ||
| zoomOut | Zooms out ||
| toggleFullscreen | Toggles fullscreen mode ||


# Markdown Viewer

Expand All @@ -61,6 +73,7 @@ Re-sizing the viewer window will reflow the markdown to fit the available space.
`md`

## Events

The Markdown viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -73,6 +86,15 @@ The Markdown viewer fires the following events
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
| printsuccess | An attempt to print triggered successfully ||

## Methods

The following methods are available for the Markdown viewer.

| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| print | Prints text using Github Markdown styling ||
| toggleFullscreen | Toggles fullscreen mode ||


# Text Viewer

Expand All @@ -91,6 +113,7 @@ Re-sizing the viewer window will reflow the text to fit the available space and
This viewer supports printing and will attempt to print with appropriate syntax highlighting when either `print()` is invoked or the print button is pressed. Note that printing large files may cause some browsers to hang for a few seconds.

### Controls:

* Zoom In
* Zoom Out
* Fullscreen: can be exited with the escape key
Expand All @@ -101,6 +124,7 @@ This viewer supports printing and will attempt to print with appropriate syntax


## Events

The text viewer fires the following events

| Event Name | Explanation | Event Data |
Expand All @@ -113,3 +137,14 @@ The text viewer fires the following events
| resize | The preview resizes | 1. {number} **height**: window height 2. {number} **width**: window width |
| zoom | The preview zooms in or out | 1. {number} **zoom**: new zoom value 2. {boolean} **canZoomIn**: true if the viewer can zoom in more 3. {boolean} **canZoomOut**: true if the viewer can zoom out more |
| printsuccess | An attempt to print triggered successfully ||

## Methods

The following methods are available for the text viewer.
| Method Name | Explanation | Method Parameters |
| --- | --- | --- |
| zoom | Zooms in or out based on the given value | {string} 'in' or 'out' |
| zoomIn | Zooms in ||
| zoomOut | Zooms out ||
| print | Prints text ||
| toggleFullscreen | Toggles fullscreen mode ||

0 comments on commit 48f681d

Please sign in to comment.