npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lancercomet/muso

v0.1.0

Published

Yet another photo viewer. Especially designed for manga reading.

Downloads

4

Readme

Muso

logo

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 to target canvas element.
  mount (canvas: HTMLCanvasElement): void
  
  // Destroy muso instance.
  destroy (): void

  // Add an image to the end.  
  addImage (url: string): number
  
  // Prepend an image to the front.
  prependImage (url: string): number
  
  // Remove an image at specific index.
  removeImage (index: number): void
  
  // Reload target index.
  reload (index: number): void
  
  // Pagination.
  goPrevPage(): void
  goNextPage(): void
  goTargetPage(page: number): void

  // Set scrolling mode.
  setScrollingMode(mode: ScrollingMode): void
  
  // Set flip direction in Horizontal scrolling mode.
  setHorizontalDirection (direction: HorizontalDirection): Promise<void>
  
  // Events.
  on(eventName: EventType, callback: EventBusCallback): void
  off(eventName: EventType, callback: EventBusCallback): void
  
  constructor(option?: Partial<IMusoOption>)
}
interface IMusoOption {
  /**
   * Enable auto resizing.
   * 
   * @default true
   */
  autoResizing: boolean

  /**
   * The background color of Muso.
   * 
   * @default #222
   */
  stageColor: string

  /**
   * The padding around every images.
   * 
   * @default 0
   */
  stagePadding: number

  /**
   * How many pixels should user swipe to trigger paging.
   * 
   * @default 150
   */
  swipeDistanceOfPaging: number

  /**
   * How many images to display at same time.
   * 
   * @default 5
   */
  renderingImageCount: number

  /**
   * The flip direction in Horizontal Scrolling Mode.
   * 
   * @default HorizontalDirection.LTR
   */
  horizontalDirection: HorizontalDirection

  /**
   * The max display width of the image.
   * 
   * @default () => 0
   */
  maxWidth: () => number

  /**
   * The min display width of the image.
   *
   * @default () => 0
   */
  minWidth: () => number

  /**
   * The max display height of the image.
   *
   * @default () => 0
   */
  maxHeight: () => number

  /**
   * The min display height of the image.
   *
   * @default () => 0
   */
  minHeight: () => number

  /**
   * The image will scale to 1.0 if the current scale factor is less than this value.
   * 
   * @default 1.3
   */
  restoreScaleRate: number

  /**
   * The scrolling mode of Muso.
   * Horizontal and Vertical.
   * 
   * @default ScrollingMode.Horizontal
   */
  scrollingMode: ScrollingMode

  /**
   * If true, built-in input will be unavailable (like touching).
   * You can use the "swiper" object to manipulate Muso.
   * 
   * @default false
   */
  noDefaultControl: boolean

  /**
   * This function will be invoked before every single image was loaded. 
   * 
   * @default null
   */
  beforeImageLoad: (url: string) => Promise<string>

  /**
   * The acceleration ratio in vertical scrolling mode.
   * 
   * @default 1.35
   */
  vTouchMoveAcc: number

  /**
   * The acceleration ratio for zooming.
   * 
   * @default 1.05
   */
  zoomTouchMoveAcc: number

  /**
   * The placeholder image.
   * 
   * @default null
   */
  placeholder: HTMLImageElement | HTMLCanvasElement | ImageBitmap

  /**
   * Image loading timeout.
   * 
   * @default 5000
   */
  imageTimeout: number

  /**
   * The rendering alpha for non current page.
   * 
   * @default 1
   */
  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.