tify-iiif-viewer / tify

TIFY is a slim and mobile-friendly IIIF document viewer.
GNU Affero General Public License v3.0
107 stars 27 forks source link
iiif

TIFY

TIFY is a slim and mobile-friendly IIIF document viewer built with Vue.js. It supports IIIF Presentation API and Image API version 2 and 3.

Continue reading to learn how to integrate TIFY into your website or application and about its options and API, check out the website for usage examples, or have a look at the user guide.

Embedding TIFY

TIFY is available as an npm package:

npm install tify

Embed TIFY into your website in three easy steps:

  1. Include both the JavaScript and the stylesheet.

    • Either download TIFY and copy the contents of the dist directory to your server:

      <script src="https://github.com/tify-iiif-viewer/tify/raw/main/tify.js?v0.31.0"></script>
      <link rel="stylesheet" href="https://github.com/tify-iiif-viewer/tify/blob/main/tify.css?v0.31.0">

      To avoid issues with browser caching, add a query parameter with the current version, e.g. ?v0.31.0.

    • Or use jsDelivr:

      <script src="https://cdn.jsdelivr.net/npm/tify@0.31.0/dist/tify.js"></script>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tify@0.31.0/dist/tify.css">
    • Or import TIFY into your web application:

      import 'tify'
      import 'tify/dist/tify.css'
  2. Add an HTML block element with an id and set its height.

    <div id="tify" style="height: 640px"></div>
  3. Create a TIFY instance.

    <script>
    new Tify({
      container: '#tify',
      manifestUrl: 'https://example.org/iiif-manifest.json',
    })
    </script>

Many aspects of the theme can be modified with SCSS variables or CSS custom properties, allowing you to easily adapt TIFY’s appearance to your website. See the theme settings file for all available variables.

Upgrading

If you are are upgrading from any previous version, have a look at the upgrading guidelines.

Options

TIFY takes an options object as its only parameter. While optional, you usually want to set container and manifestUrl.

An example with most available options set to non-default values:

new Tify({
  container: '#tify',
  language: 'de',
  manifestUrl: 'https://example.org/iiif-manifest.json',
  pageLabelFormat: 'P (L)',
  pages: [2, 3],
  pan: { x: .45, y: .6 },
  translationsDirUrl: '/translations/tify',
  urlQueryKey: 'tify',
  urlQueryParams: ['pages'],
  view: '',
  viewer: {
    immediateRender: false,
  },
  zoom: 1.2,
})

API

With the exception of mount and destroy, all API functions are only available after TIFY has been mounted and the manifest has been loaded. Then the ready promise is fulfilled. There is no API function to load a new manifest; just replace the instance.

Use the API like this:

const tify = new Tify({ manifestUrl: 'https://example.org/iiif-manifest.json' })

tify.mount('#tify')

tify.ready.then(() => {
  tify.setPage([1, 12, 13])
  tify.setView('thumbnails')
  tify.viewer.viewport.zoomTo(2)
})

OpenSeadragon API

The viewer object exposes the full OpenSeadragon API. If you want to control the scan view programmatically, the methods of viewer.viewport are probably of interest.

Build Setup

You need to have Node.js v18.0 or above, npm (usually comes with Node.js) and git installed.

Install dependencies:

npm install

Run in development mode with hot reload and automatic linting:

npm run dev

Build for production with minification:

npm run build

The production build will be stored in dist.

Running Tests

Run unit tests: npm run test:unit

Run end-to-end tests:


Göttingen State and University Library