@prose-reader/enhancer-hammer-gesture

This enhancer implement common gesture patterns using hammer. Tap on edge to turn pages, pinch to change font scale, etc. If you use hammer on your project you might want to use this package to benefits from its features.

Options

  • enableFontScalePinch?: boolean

    • Enable pinch to change font scale feature. Make sure you enabled pinch recognizer on hammer for this to work.

  • fontScaleMin?: number

    • Define the min font scale value possible.

  • fontScaleMax?: number

    • Define the max font scale value possible.

  • managerInstance?: HammerManager

    • Hammer instance. Depending on where you initialize your hammer instance it might be more convenient to pass it here or later with instance setter.

Example

import { createReader } from "@prose-reader/core"
import { hammerGestureEnhancer } from "@prose-reader/enhancer-hammer-gesture"

const createAppReader = hammerGestureEnhancer(createReader)

const hammer = new Hammer(document.getElementById("reader-container"))

const reader = createAppReader({
  containerElement: document.getElementById("reader"),
  hammerGesture: {
    managerInstance: hammer,
    enableFontScalePinch: true,
    fontScaleMax: 5,
    fontScaleMin: 0.2
  }
})

Pinch to change font scale

By pinching in and out user can change the font scale. This is a common pattern on e-ink tablet to change the font scale.

Last updated