BoundCamera
class BoundCamera extends Camera
A Camera that set range not to go out of the first/last panel, so it won't show empty spaces before/after the first/last panel
Properties
element
The camera(.flicking-camera
) element
Type: HTMLElement
position
Current position of the camera
Type: number
alignPosition
Align position inside the viewport where Panel's alignPosition should be located at
Type: number
offset
Position offset, used for the renderOnlyVisible option
Type: number
Default: 0
range
A range that Camera's position can reach
Type: object
PROPERTY | TYPE | DESCRIPTION |
---|---|---|
min | number | A minimum position |
min | number | A maximum position |
rangeDiff
A difference between Camera's minimum and maximum position that can reach
Type: number
visiblePanels
An array of visible panels from the current position
Type: Array<Panel>
visibleRange
A range of the visible area from the current position
Type: object
PROPERTY | TYPE | DESCRIPTION |
---|---|---|
min | number | A minimum position |
min | number | A maximum position |
anchorPoints
An array of AnchorPoints that Camera can be stopped at
Type: Array<AnchorPoint>
controlParams
A current parameters of the Camera for updating AxesController
Type: object
PROPERTY | TYPE | DESCRIPTION |
---|---|---|
range | object | Camera range |
position | number | Current position |
circular | boolean | A Boolean indicating whether the circular option is enabled |
atEdge
A Boolean value indicating whether Camera's over the minimum or maximum position reachable
Type: boolean
size
Return the size of the viewport
Type: number
progress
Return the camera's position progress from the first panel to last panel
Range is from 0 to last panel's index
Type: number
align
A value indicating where the alignPosition should be located at inside the viewport element
Type: ALIGN | string | number
Methods
updateRange
Update range of Camera
Returns: this
Throws: FlickingError
NOT_ATTACHED_TO_FLICKING When init is not called before
init
Initialize Camera
Returns: this
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
flicking | Flicking | no | An instance of Flicking |
Throws: FlickingError
VAL_MUST_NOT_NULL If the camera element(.flicking-camera
) does not exist inside viewport element
destroy
Destroy Camera and return to initial state
Returns: void
lookAt
Move to the given position and apply CSS transform
Returns: this
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
pos | number | no | A new position |
Throws: FlickingError
NOT_ATTACHED_TO_FLICKING When init is not called before
getPrevAnchor
Return a previous AnchorPoint of given AnchorPoint
If it does not exist, return null
instead
Returns: AnchorPoint | null
- The previous AnchorPoint
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
anchor | AnchorPoint | no | A reference AnchorPoint |
getNextAnchor
Return a next AnchorPoint of given AnchorPoint
If it does not exist, return null
instead
Returns: AnchorPoint | null
- The next AnchorPoint
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
anchor | AnchorPoint | no | A reference AnchorPoint |
getProgressInPanel
Return the camera's position progress in the panel below
Value is from 0 to 1 when the camera's inside panel
Value can be lower than 0 or bigger than 1 when it's in the margin area
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
panel | Panel | no |
findAnchorIncludePosition
Return AnchorPoint that includes given position
If there's no AnchorPoint that includes the given position, return null
instead
Returns: AnchorPoint | null
- The AnchorPoint that includes the given position
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
position | number | no | A position to check |
findNearestAnchor
Return AnchorPoint nearest to given position
If there're no AnchorPoints, return null
instead
Returns: AnchorPoint | null
- The AnchorPoint nearest to the given position
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
position | number | no | A position to check |
clampToReachablePosition
Clamp the given position between camera's range
Returns: number
- A clamped position
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
position | number | no | A position to clamp |
canReach
Check whether the given panel is inside of the Camera's range
Returns: boolean
- Whether the panel's inside Camera's range
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
panel | Panel | no | An instance of Panel to check |
canSee
Check whether the given panel element is visible at the current position
Returns: boolean
- Whether the panel element is visible at the current position
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
panel | Panel | no | An instance of Panel to check |
updateAlignPos
Update Camera's alignPosition
Returns: this
updateAnchors
Update Camera's anchorPoints
Returns: this
Throws: FlickingError
NOT_ATTACHED_TO_FLICKING When init is not called before
updateAdaptiveHeight
Update Viewport's height to active panel's height
Returns: this
Throws: FlickingError
NOT_ATTACHED_TO_FLICKING When init is not called before
resetNeedPanelHistory
Reset the history of needPanel events so it can be triggered again
Returns: this