Class gui.ZoomHelper
Defined in: ZoomHelper.js.
Constructor Attributes | Constructor Name and Description |
---|---|
ZoomHelper handles touch gestures and provides pinch-to-zoom support
on the sizer element.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
gui.ZoomHelper.signalZoomChanged
|
Method Attributes | Method Name and Description |
---|---|
<inner> |
applyCSSTransform(x, y, scale, is3D)
Apply a 3D or 2D CSS transform with the given
x and y offset, and scale.
|
<inner> |
Applies the current zoom as a detailed
rendering.
|
<inner> |
Applies the current computed zoom & pan
as a quick-and-dirty rendering, to be used
during a gesture or when a flicker needs
to be masked.
|
<inner> |
applyTransform(is3D)
Apply the current computed transform
(including pan and zoom)
|
destroy(callback,)
|
|
<inner> |
enableScrollBars(enable)
Enable or disable virtual scrollbars on the container.
|
<inner> |
getPoint(touch)
Returns a Point instance for a given touch.
|
<inner> |
prepareGesture(event)
|
<inner> |
processGesture(event)
|
<inner> |
processPan(point)
Takes a point in page coordinates and pans towards it
|
<inner> |
processPinch(point1, point2)
|
<inner> |
processZoom(zoomPoint, incrementalZoom)
Takes a point and a relative zoom factor,
with which the panPoint is accordingly updated
to reflect the new zoom center, and the current
zoom level is multiplied by the relative factor.
|
<inner> |
Adds touchstart, touchmove, and touchend
event listeners to the element's scrollable
container.
|
<inner> |
Sets the scrolling of the container to (0,0)
so that transforms and event points can be
conveniently computed.
|
<inner> |
Restores the scrollTop and scrollLeft of
the container to the x and y pan values.
|
<inner> |
Restores scroll to the current pan position
after the gesture is over.
|
<inner> |
sanitizePointForPan(point)
Returns the closest point to the given point
within the boundaries of the zoomable element,
such that it never causes panning outside
the viewport.
|
setZoomableElement(element)
FIXME: I don't like that we can switch the zoomable
element at runtime, but I don't see any other way to
keep the zoom helper working after an undo.
|
|
setZoomLevel(zoomLevel)
|
|
subscribe(eventid, cb)
|
|
<inner> | |
unsubscribe(eventid, cb)
|
Class Detail
gui.ZoomHelper()
ZoomHelper handles touch gestures and provides pinch-to-zoom support
on the sizer element. It also provides some methods to set, get, and
subscribe to the current zoom level.
Field Detail
<static>
gui.ZoomHelper.signalZoomChanged
Method Detail
<inner>
{undefined}
applyCSSTransform(x, y, scale, is3D)
Apply a 3D or 2D CSS transform with the given
x and y offset, and scale.
- Parameters:
- {!number} x
- {!number} y
- {!number} scale
- {!boolean} is3D
- Returns:
- {undefined}
<inner>
{undefined}
applyDetailedTransform()
Applies the current zoom as a detailed
rendering. This is a slow call to be done
post-gesture.
- Returns:
- {undefined}
<inner>
{undefined}
applyFastTransform()
Applies the current computed zoom & pan
as a quick-and-dirty rendering, to be used
during a gesture or when a flicker needs
to be masked.
- Returns:
- {undefined}
<inner>
{undefined}
applyTransform(is3D)
Apply the current computed transform
(including pan and zoom)
- Parameters:
- {!boolean} is3D
- Returns:
- {undefined}
{undefined}
destroy(callback,)
- Parameters:
- {!function(!Error=)} callback,
- passing an error object in case of error
- Returns:
- {undefined}
<inner>
{undefined}
enableScrollBars(enable)
Enable or disable virtual scrollbars on the container.
- Parameters:
- {!boolean} enable
- Returns:
- {undefined}
<inner>
{!Point}
getPoint(touch)
Returns a Point instance for a given touch.
- Parameters:
- {!Touch} touch
- Returns:
- {!Point}
{!number}
getZoomLevel()
- Returns:
- {!number}
<inner>
{undefined}
prepareGesture(event)
- Parameters:
- {!TouchEvent} event
- Returns:
- {undefined}
<inner>
{undefined}
processGesture(event)
- Parameters:
- {!TouchEvent} event
- Returns:
- {undefined}
<inner>
{undefined}
processPan(point)
Takes a point in page coordinates and pans towards it
- Parameters:
- {!Point} point
- Returns:
- {undefined}
<inner>
{undefined}
processPinch(point1, point2)
- Parameters:
- {!Point} point1
- {!Point} point2
- Returns:
- {undefined}
<inner>
{undefined}
processZoom(zoomPoint, incrementalZoom)
Takes a point and a relative zoom factor,
with which the panPoint is accordingly updated
to reflect the new zoom center, and the current
zoom level is multiplied by the relative factor.
Useful for when the zoom is dynamically being changed
during a gesture.
This does not zoom beyond a minimum reasonable zoom
level. Since we assume that gestures are for a
mobile device, it makes some sense to not allow
shrinking of a document to a width less than the container's
width. Also easier for computation of pan coordinates.
- Parameters:
- {!Point} zoomPoint
- {!number} incrementalZoom
- Returns:
- {undefined}
<inner>
{undefined}
registerGestureListeners()
Adds touchstart, touchmove, and touchend
event listeners to the element's scrollable
container.
- Returns:
- {undefined}
<inner>
{undefined}
removeScroll()
Sets the scrolling of the container to (0,0)
so that transforms and event points can be
conveniently computed.
Applies a quick transform to make it look like
this never happened.
- Returns:
- {undefined}
<inner>
{undefined}
restoreScroll()
Restores the scrollTop and scrollLeft of
the container to the x and y pan values.
Applies a quick transform to make it look like
this never happened.
- Returns:
- {undefined}
<inner>
{undefined}
sanitizeGesture()
Restores scroll to the current pan position
after the gesture is over.
- Returns:
- {undefined}
<inner>
{!Point}
sanitizePointForPan(point)
Returns the closest point to the given point
within the boundaries of the zoomable element,
such that it never causes panning outside
the viewport.
- Parameters:
- {!Point} point
- Returns:
- {!Point}
{undefined}
setZoomableElement(element)
FIXME: I don't like that we can switch the zoomable
element at runtime, but I don't see any other way to
keep the zoom helper working after an undo.
- Parameters:
- {!HTMLElement} element
- Returns:
- {undefined}
{undefined}
setZoomLevel(zoomLevel)
- Parameters:
- {!number} zoomLevel
- Returns:
- {undefined}
{undefined}
subscribe(eventid, cb)
- Parameters:
- {!string} eventid
- {!Function} cb
- Returns:
- {undefined}
<inner>
{undefined}
unregisterGestureListeners()
- Returns:
- {undefined}
{undefined}
unsubscribe(eventid, cb)
- Parameters:
- {!string} eventid
- {!Function} cb
- Returns:
- {undefined}