Skip to content

Diva.js 5.0.0

Compare
Choose a tag to compare
@jeromepl jeromepl released this 25 Aug 15:04
· 328 commits to master since this release

New Features

  • Diva now uses canvas-based rendering.
    This also means that most DOM elements inside of .diva-inner have been removed and code relying on looking up those elements will fail.
  • Diva will now fill its parent height by default. This uses a flexbox layout and can be disabled with the setting fillParentHeight.
    In order to implement this and fix other issues, the DOM hierarchy has changed. See below for a detailed log of what has changed in the DOM.
  • Support for pages marked as 'non-paged' in IIIF manifests.
    A new button has been added to the toolbar to toggle the visibility of non-paged pages. If no non-paged pages are present in the document, the button will be hidden.
    The button can be hidden manually with the setting enableNonPagedVisibilityIcon, and non-paged pages can be shown on document load with the setting showNonPagedPages.
  • Usage of the older Diva JSON format is now officially deprecated, and will be completely removed in the next version of Diva. Consider switching to IIIF manifests (See http://iiif.io/ for more information).
  • The 'go to page' form in the toolbar now uses page labels to go to a specific page. Suggestions are also shown to help the user see what page labels are available. Also, a new hook is now available to override the behaviour of this form (See the onGotoSubmit setting).
    If no page label matches, Diva will try to parse a page index. The behaviour for this form can be overridden using the onGotoSubmit setting.
  • Continuous Zooming. Zoom levels can now be fractions. Also, the current images will be zoomed while waiting for the new higher resolution images to be loaded from the server.

Bug fixes

Multiple bug fixes are introduced in this version of Diva. Here are the biggest ones:

  • The Diva instance now correctly terminates if the destroy() method is called before the viewer finishes loading.
  • The size of the .diva-inner element is now properly updated when the viewer is resized. It used to only be set when a view was loaded.
  • The gotoPageBy__ methods now also work in Grid view.

Plugin System Changes

  • Register plugins via window.diva.registerPlugin(...), instead of pushing to window.divaPlugins.

Public Methods Changes

New Methods:

  • getPageDimensionsAtCurrentZoomLevel(pageIndex): Returns the dimensions of a given page at the current zoom level, no matter what view the document is in.
  • isPageIndexValid(pageIndex): Returns true if a page index is within the range of the document and, if the page is marked as 'non-paged', if the non-paged pages are currently visible.
  • toggleNonPagedPagesVisibility(): Shows/Hides pages tagged as 'non-paged' in the (IIIF only) manifest.
  • showNonPagedPages(): Shows pages tagged as 'non-paged'.
  • hideNonPagedPages(): Hides pages tagged as 'non-paged'.
  • getAliasForPageIndex: Returns the first of these three that resolves to boolean true (Else the function will return false):
    -Explicit alias as defined in pageAliases
    -Result of pageAliasFunction
    -originalPageIndex + 1 (to simulate the original mapping)
  • getPageIndexForAlias: Returns the first page index found for a given aliased number or false if not found.
  • getPageIndicesForAlias: Returns array of page indices for a given aliased number. Returns an empty array if none are found.
  • getCurrentAliasedPageIndex: Same as getAliasForPageIndex but uses the current page index automatically.
  • gotoPageByAliasedNumber: Go to a specific page based on its alias.

Changes to Existing Methods:

  • getSettings(): The settings object returned is now read-only.
  • inViewport(): Has been renamed isRegionInViewport().
  • getCurrentPageDimensionsAtCurrentZoomLevel(): Now also works in grid view.
  • isRegionInViewport (previously called inViewport): Now accepts a page index instead of a page number as an argument.
  • getPageIndexForPageXYValues(pageX, pageY): Now returns -1 (instead of false) if no page was found.
  • getCurrentPageFilename(): For IIIF manifests, this method now returns the URL of the image for that page.

Deprecated Methods:

  • gotoPageByNumber(pageNumber): Use gotoPageByIndex(pageIndex) instead.
  • getCurrentPageNumber(): Use getCurrentPageIndex() instead.
  • isPageLoaded(pageIndex): Use isPageInViewport(pageIndex) instead.
  • getPageDimensionsAtCurrentGridLevel(pageIndex): Use getPageDimensionsAtCurrentZoomLevel(pageIndex) instead.

Settings Changes

New Settings:

  • onGotoSubmit: When set to a function that takes a string and returns a page index, this will override the default behaviour of the 'go to page' form submission. If the function returns false or null, a message is displayed to the user saying that the page was not found. By default Diva uses the public method gotoPageByLabel.
  • enableGotoSuggestions: Controls whether suggestions are shown when a user is typing in the 'go to page' form. Default: true
  • fillParentHeight: When set to true, Diva will use a flexbox layout to fill its parent's height. Default: true
  • enableNonPagedVisibilityIcon: show or hide the icon in the toolbar that toggles visibility of non-paged pages. Note that the icon is automatically hidden if there are no non-paged pages in the current document. Default: true
  • showNonPagedPages: Whether pages tagged as ‘non-paged’ (in IIIF manifests only) should be visible after initial load. Default: false
  • hashParamSuffix: Allows customization of the hash params used to generate a custom URL to recreate the current view. Useful when a single page application deletes and re-instantiates multiple Diva viewers. Default: ''
  • pageAliases: An object mapping specific page indices to their alias. (Has priority over the 'pageAliasFunction' setting.
  • pageAliasFunction: A function mapping page indices to an alias. If false is returned, default page number is displayed.
    If none of the above two settings are specified when instantiating Diva, the regular page number will be displayed in the toolbar.

Removed Settings:

  • rowLoadTimeout

Events Changes

New Events:

  • ViewerWillTerminate [settings]: Similarly to 'ViewerDidTerminate', fires when the destroy() method is called on a Diva instance. The difference is that this method fires at the start of the 'destroy' process, rather then at the end.
    Useful to access diva elements and data attached to them before it all gets destroyed.

DOM Changes

  • A new element now wraps all other elements created by Diva: .diva-wrapper
  • A new element now sits in between .diva-outer and .diva-inner: .diva-viewport
  • Most DOM elements that used to contain image tiles in .diva-inner do not exist anymore, since those are now all rendered on a canvas.
  • All IDs of DOM elements generated by Diva are now of the form diva-n-foo, where 'n' is the ID of the Diva instance.

The global DOM hierarchy thus now looks like this:
.diva-wrapper > .diva-outer > .diva-viewport > .diva-inner. The canvas is a child of .diva-outer and the toolbar is (by default) a child of .diva-wrapper