new InfiniteViewer(_containerElement, viewportElementopt, optionsopt)
Name | Type | Default | Description |
---|---|---|---|
_containerElement |
HTMLElement | ||
viewportElement ? |
HTMLElement | Partial<InfiniteViewerOptions> |
{}
|
|
options ? |
Partial<InfiniteViewerOptions> |
{}
|
Members
(static, constant) PROPERTIES
(static, constant) OPTIONS
(static, constant) METHODS
(static, constant) EVENTS
(static, constant) CLASS_NAME
Methods
zoomBy(deltaZoom, optionsopt)
Set viewer zoom by the given amount
Name | Type | Description |
---|---|---|
deltaZoom |
number | number[] | |
options ? |
ZoomOptions |
trigger<Name extends keyof Events>(eventName, paramopt) → {boolean}
- Source:
- Overrides:
Fires an event to call listeners.
Name | Type | Default | Description |
---|---|---|---|
eventName |
Name | ... | Event name | |
param ? |
TargetParam<any> | ... |
{}
|
Event parameter |
trigger<Name extends keyof Events, Param = Events[Name]>(eventName) → {boolean}
Name | Type | Description |
---|---|---|
eventName |
extends TargetParam<Param> ? Name : never |
trigger<Name extends keyof Events, Param = Events[Name]>(eventName, param) → {boolean}
Name | Type | Description |
---|---|---|
eventName |
Name | |
param |
TargetParam<Param> |
Example
import EventEmitter from "@scena/event-emitter";
const emitter = new EventEmitter();
emitter.on("a", e => {
});
emitter.emit("a", {
a: 1,
});
Returns:
If false, stop the event.
- Type
- boolean
setZoom(zoom, optionsopt)
Set viewer zoom
Name | Type | Description |
---|---|---|
zoom |
number | number[] | |
options ? |
ZoomOptions |
setTo(options)
- Source:
- Since:
Move to that position or zoom.
Name | Type | Description |
---|---|---|
options |
SetOptions |
setBy(options)
- Source:
- Since:
Move by the position or zoom delta value.
Name | Type | Description |
---|---|---|
options |
SetOptions |
scrollTo(scrollLeft, scrollTop, optionsopt)
Scrolls the container to set of coordinates.
Name | Type | Description |
---|---|---|
scrollLeft |
number | |
scrollTop |
number | |
options ? |
ScrollOptions |
scrollCenter(optionsopt)
Scroll the element to the center
Name | Type | Default | Description |
---|---|---|---|
options ? |
ScrollCenterOptions |
{}
|
scrollBy(deltaX, deltaY, optionsopt)
Scrolls the container by the given amount.
Name | Type | Description |
---|---|---|
deltaX |
number | |
deltaY |
number | |
options ? |
ScrollOptions |
resize()
Update Viewer Sizes
once<Name extends keyof Events & string, Param = Events[Name]>(eventName, listeneropt) → {Promise<OnEvent<Param, this>>}
- Source:
- Inherited From:
Add a disposable listener and Use promise to the registered event.
Name | Type | Description |
---|---|---|
eventName |
Name | Name of the event to be added |
listener ? |
EventListener<Param, this> | disposable listener function of the event to be added |
Example
import EventEmitter from "@scena/event-emitter";
cosnt emitter = new EventEmitter();
// Add a disposable listener in "a" event
emitter.once("a", () => {
});
// Use Promise
emitter.once("a").then(e => {
});
Returns:
- Type
- Promise<OnEvent<Param, this>>
on(eventName, listeneropt) → {this}
- Source:
- Inherited From:
Add a listener to the registered event.
Name | Type | Description |
---|---|---|
eventName |
string | object | ... | Name of the event to be added |
listener ? |
EventListener<Events[any], this> | ... | listener function of the event to be added |
on<Name extends keyof Events, Param = Events[Name]>(eventName, listener) → {this}
Name | Type | Description |
---|---|---|
eventName |
Name | |
listener |
EventListener<Param, this> |
on(events) → {this}
Name | Type | Description |
---|---|---|
events |
EventHash<Events, this> |
Example
import EventEmitter from "@scena/event-emitter";
cosnt emitter = new EventEmitter();
// Add listener in "a" event
emitter.on("a", () => {
});
// Add listeners
emitter.on({
a: () => {},
b: () => {},
});
Returns:
- Type
- this
off(eventNameopt, listeneropt) → {this}
- Source:
- Inherited From:
Remove listeners registered in the event target.
Name | Type | Description |
---|---|---|
eventName ? |
string | object | ... | Name of the event to be removed |
listener ? |
EventListener<Events[any], this> | ... | listener function of the event to be removed |
off<Name extends keyof Events, Param = Events[Name]>(eventName, listener) → {this}
Name | Type | Description |
---|---|---|
eventName ? |
Name | |
listener ? |
EventListener<Param, this> |
off(events) → {this}
Name | Type | Description |
---|---|---|
events |
EventHash<Events, this> |
Example
import EventEmitter from "@scena/event-emitter";
cosnt emitter = new EventEmitter();
// Remove all listeners.
emitter.off();
// Remove all listeners in "A" event.
emitter.off("a");
// Remove "listener" listener in "a" event.
emitter.off("a", listener);
Returns:
- Type
- this
getZoomY()
- Source:
- Since:
Get viewer zoom
getZoomX()
- Source:
- Since:
Get viewer zoomX
getZoom()
Get viewer zoom
getWrapper() → {HTMLElement}
Get Wrapper Element
Returns:
- Type
- HTMLElement
getWheelContainer() → {HTMLElement}
Get Wheel Container Element
Returns:
- Type
- HTMLElement
getViewport() → {HTMLElement}
Get Viewport Element
Returns:
- Type
- HTMLElement
getScrollWidth(isZoomopt)
Gets measurement of the width of an element's content with overflow
Name | Type | Description |
---|---|---|
isZoom ? |
boolean |
getScrollTop(optionsopt)
Gets the number of pixels that an element's content is scrolled vertically.
Name | Type | Default | Description |
---|---|---|---|
options ? |
GetScollPosOptions | boolean |
{}
|
getScrollLeft(optionsopt)
Gets the number of pixels that an element's content is scrolled vertically.
Name | Type | Default | Description |
---|---|---|---|
options ? |
GetScollPosOptions | boolean |
{}
|
getScrollHeight(isZoomopt)
Gets measurement of the height of an element's content with overflow
Name | Type | Description |
---|---|---|
isZoom ? |
boolean |
getRangeY(isZoomopt, isRealopt)
get y ranges
Name | Type | Description |
---|---|---|
isZoom ? |
boolean | |
isReal ? |
boolean |
getRangeX(isZoomopt, isRealopt)
get x ranges
Name | Type | Description |
---|---|---|
isZoom ? |
boolean | |
isReal ? |
boolean |
getContainer() → {HTMLElement}
Get Container Element
Returns:
- Type
- HTMLElement
geScrollArea() → {HTMLElement}
Get Scroll Area Element
Returns:
- Type
- HTMLElement
emit(eventName, paramopt) → {boolean}
- Source:
- Inherited From:
Fires an event to call listeners.
Name | Type | Default | Description |
---|---|---|---|
eventName |
string | ... | Event name | |
param ? |
TargetParam<any> | ... |
{}
|
Event parameter |
emit<Name extends keyof Events, Param = Events[Name]>(eventName) → {boolean}
Name | Type | Description |
---|---|---|
eventName |
extends Param ? Name : never |
emit<Name extends keyof Events, Param = Events[Name]>(eventName, param) → {boolean}
Name | Type | Description |
---|---|---|
eventName |
Name | |
param |
TargetParam<Param> |
Example
import EventEmitter from "@scena/event-emitter";
const emitter = new EventEmitter();
emitter.on("a", e => {
});
emitter.emit("a", {
a: 1,
});
Returns:
If false, stop the event.
- Type
- boolean
destroy() → {void}
Destroy elements, properties, and events.
Returns:
- Type
- void
Type Definitions
AnimationOptions
Properties:
Type:
- TSInterface
GetScollPosOptions
Properties:
absolute
optional
Default Value: false
absolute?:
boolean
How to get scroll pos
Whether to calculate scroll amount based on screen (client)
Type:
- TSInterface
InfiniteViewerOptions
Properties:
Default Value: 1
zoom:
number
viewer's zoom
If you use the zoomX and zoomY properties, don't use the zoom property.
Default Value: [0, 0]
rangeOffsetX:
number[]
Horizontal scroll range offset not affected by zoom [Left, Right]
Default Value: [0, 0]
rangeOffsetY:
number[]
Vertical scroll range offset not affected by zoom [Top, Bottom]
Default Value: "50%"
zoomOffsetX:
number | string
Offset left position for zoom operation
Default Value: "50%"
zoomOffsetY:
number | string
Offset top position for zoom operation.
Default Value: false
usePinch:
boolean
Whether to pinch the scroll motion when the touch event is activated.
Default Value: 50
pinchThreshold:
number
Threshold at which pinch can be operated when the usePinch option is used.
Default Value: false
useAutoZoom:
boolean
Whether zoom automatically updates when pinch occurs through wheel, gesture, or touch
Default Value: true
useWheelPinch:
boolean
Whether to use wheel pinch. you can pinch using the ctrl key.
Default Value: "ctrl"
wheelPinchKey:
"ctrl" | "meta" | "alt" | "shift"
Key to use wheel pinch
Default Value: IS_SAFARI
useWheelScroll:
boolean
Whether to use wheel scroll. You can scroll smoothly by using the wheel.
Default Value: false
useBounceScrollBar:
boolean
Whether or not to use a scroll bar in the form of a bounce
An early version of InfiniteViewer's scroll bar.
Default Value: false
useOverflowScroll:
boolean
Whether to scroll when the content is larger than the screen even if the range is limited
Default Value: true
useGesture:
boolean
Whether to use gestures using trackpad or magic mouse.
Default Value: Infinity
maxPinchWheel:
number
The max value of the wheel for pinch. If the wheel weight is too large, it can be adjusted.
wheelContainer
optional
Default Value: containerElement
wheelContainer?:
HTMLElement | string | {current?: HTMLElement | undefined | null, value?: HTMLElement | undefined | null}
The container element to which the wheel event applies
Default Value: true
displayVerticalScroll:
boolean
Whether to show vertical scroll bar
Default Value: true
displayHorizontalScroll:
boolean
Whether to show horizontal scroll bar
Default Value: true
useTransform:
boolean
Whether to use the transform property. If you don't use it, you can't use zoom.
Default Value: false
useResizeObserver:
boolean
Whether to use the resize observer
Default Value: true
preventWheelClick:
boolean
Whether to prevent dragging through the wheel button
Since:
0.20.0
zoomX:
number
viewer's zoomX
If you use the zoom property, don't use the zoomX and zoomY properties.
Since:
0.20.0
zoomY:
number
viewer's zoomY
If you use the zoom property, don't use the zoomX and zoomY properties.
Since:
0.20.0
Default Value: "all"
pinchDirection:
"all" | "horizontal" | "vertical"
pinch direction
If only one direction is set, only the zoom value in that direction is changed.
Type:
- TSInterface
OnAbortPinch
Properties:
Type:
- TSInterface
OnDrag
Properties:
Type:
- TSInterface
OnDragEnd
Properties:
Type:
- TSInterface
OnDragStart
Type:
- TSInterface
OnPinch
Properties:
Type:
- TSInterface
OnPinchStart
Properties:
Type:
- TSInterface
OnScroll
Properties:
Type:
- TSInterface
ScrollCenterOptions
Properties:
absolute
optional
Default Value: false
absolute?:
boolean
How to calculate delta and scroll amount
Whether to calculate scroll amount based on screen (client)
Type:
- TSInterface
ScrollOptions
Properties:
absolute
optional
Default Value: false
absolute?:
boolean
How to calculate delta and scroll amount
Whether to calculate scroll amount based on screen (client)
Type:
- TSInterface
SetOptions
- Source:
- Since:
Properties:
zoomOffsetX
optional
zoomOffsetX?:
number | string
The x, y coordinates of the zoom operation based on the viewport
zoomOffsetY
optional
zoomOffsetY?:
number | string
The x, y coordinates of the zoom operation based on the viewport
Type:
- TSInterface
ZoomOptions
Properties:
zoomBase
optional
Default Value: "screen"
zoomBase?:
"screen" | "viewport" | "fixed"
how to calculate zoom offset
Type:
- TSInterface
Events
abortPinch
the `abortPinch` event fires when `pinch` event does not occur by dragging a certain area.
Type | Description |
---|---|
InfiniteViewer.OnAbortPinch | Parameters for the abortPinch event |
Example
import InfiniteViewer from "infinite-viewer";
const viewer = new InfiniteViewer(
document.querySelector(".container"),
document.querySelector(".viewport"),
{
usePinch: true,
}
).on("abortPinch", e => {
console.log(e.inputEvent);
});
drag
the `drag` event fires when `touch` does occur.
Type | Description |
---|---|
InfiniteViewer.OnDrag | Parameters for the `drag` event |
Example
import InfiniteViewer from "infinite-viewer";
const viewer = new InfiniteViewer(
document.querySelector(".container"),
document.querySelector(".viewport"),
).on("drag", e => {
console.log(e.inputEvent);
});
dragEnd
the `dragEnd` event fires when `touchend` does occur.
Type | Description |
---|---|
InfiniteViewer.OnDragEnd | Parameters for the `dragEnd` event |
Example
import InfiniteViewer from "infinite-viewer";
const viewer = new InfiniteViewer(
document.querySelector(".container"),
document.querySelector(".viewport"),
).on("dragEnd", e => {
console.log(e.inputEvent);
});
dragStart
the `dragStart` event fires when `touchstart` does occur.
Type | Description |
---|---|
InfiniteViewer.OnDragStart | Parameters for the `dragStart` event |
Example
import InfiniteViewer from "infinite-viewer";
const viewer = new InfiniteViewer(
document.querySelector(".container"),
document.querySelector(".viewport"),
).on("dragStart", e => {
console.log(e.inputEvent);
});
pinch
the `pinch` event fires when two points pinch the viewer
The pinchStart and abortPinch events do not occur when pinching through the wheel.
Type | Description |
---|---|
InfiniteViewer.OnPinch | Parameters for the `pinch` event |
Example
import InfiniteViewer from "infinite-viewer";
const viewer = new InfiniteViewer(
document.querySelector(".container"),
document.querySelector(".viewport"),
{
usePinch: true,
}
).on("pinch", e => {
console.log(e.zoom, e.inputEvent);
});
scroll
The `scroll` event fires when the document view or an element has been scrolled.
Type | Description |
---|---|
InfiniteViewer.OnScroll | Parameters for the scroll event |
Example
import InfiniteViewer from "infinite-viewer";
const viewer = new InfiniteViewer(
document.querySelector(".container"),
document.querySelector(".viewport"),
).on("scroll", () => {
console.log(viewer.getScrollLeft(), viewer.getScrollTop());
});