Muso

Yet another photo viewer. Especially designed for manga reading.
It is completely canvas-based, aims to have native-like touching experience.
Feature
- Implement in canvas. Native-like touching experience.
- Reactive sizing. Suitable for all type of devices.
- Three viewing mode: left swipe, right swipe, vertical scrolling.
- Zero dependency.
Demo
- Demo - This is a basic demo showing a fullscreen Muso.
- Bilibili Manga - Please use mobile device to visit this page, otherwise it will redirect to the desktop version which is nothing to do with Muso. And this Muso is a little different from the one in the repo, some bugs are not fixed yet, and the animation is too fast if the refresh rate is > 60 fps.
Quick Start
import { Muso } from '@lancercomet/muso'
const myCanvas = document.querySelector('#my-canvas')
const muso = new Muso({...})
muso.mount(myCanvas)
API
class Muso {
mount (canvas: HTMLCanvasElement): void
destroy (): void
addImage (url: string): number
prependImage (url: string): number
removeImage (index: number): void
reload (index: number): void
goPrevPage(): void
goNextPage(): void
goTargetPage(page: number): void
setScrollingMode(mode: ScrollingMode): void
setHorizontalDirection (direction: HorizontalDirection): Promise<void>
on(eventName: EventType, callback: EventBusCallback): void
off(eventName: EventType, callback: EventBusCallback): void
constructor(option?: Partial<IMusoOption>)
}
interface IMusoOption {
autoResizing: boolean
stageColor: string
stagePadding: number
swipeDistanceOfPaging: number
renderingImageCount: number
horizontalDirection: HorizontalDirection
maxWidth: () => number
minWidth: () => number
maxHeight: () => number
minHeight: () => number
restoreScaleRate: number
scrollingMode: ScrollingMode
noDefaultControl: boolean
beforeImageLoad: (url: string) => Promise<string>
vTouchMoveAcc: number
zoomTouchMoveAcc: number
placeholder: HTMLImageElement | HTMLCanvasElement | ImageBitmap
imageTimeout: number
otherPageAlpha: () => number
}
enum ScrollingMode {
Horizontal = "horizontal",
Vertical = "vertical"
}
enum HorizontalDirection {
LTR = "ltr",
RTL = "rtl"
}
enum EventType {
EnterDuoTouch = "enter-double-touch",
ImageLoadingFailure = "image-loading-failure",
LeaveDuoTouch = "leave-double-touch",
MouseWheel = "mousewheel",
ScrollingMode = "scrolling-mode",
Swipe = "touch-swipe",
TouchStart = "touch-start",
TouchMove = "touch-move",
TouchEnd = "touch-end",
TouchMoveX = "touch-move-x",
TouchMoveY = "touch-move-y",
Paging = "paging",
Resize = "resize",
Zooming = "zooming",
ZoomCenterMove = "zoom-center-move"
}
License
Apache-2.0
Logo was generated by MidJourney.