@driftory/viewer
Advanced tools
Comparing version 0.2.1 to 0.2.2
/// <reference types="openseadragon" /> | ||
import { Comic } from './Comic.types'; | ||
export * from './Comic.types'; | ||
export * from './openseadragon.types'; | ||
import { OpenSeadragonType, ViewerType } from './openseadragon.types'; | ||
@@ -24,10 +22,24 @@ declare global { | ||
declare type OnNoPrevious = (params: {}) => void; | ||
interface DriftoryArguments { | ||
export interface DriftoryArguments { | ||
/** The HTML DOM element that the Driftory Comic will be rendered in. */ | ||
container: Container; | ||
/** | ||
* This library has a dependency on the [OpenSeadragon](https://openseadragon.github.io/) library. | ||
* | ||
* By default, OpenSeadragon will be loaded from [the JS Deliver CDN](https://cdn.jsdelivr.net/npm/openseadragon@2.4/build/openseadragon/openseadragon.min.js) | ||
* while initializing. | ||
* | ||
* To prevent this, you can use this parameter to provide your own instance of OpenSeaDragon instead. | ||
* */ | ||
OpenSeadragon?: OpenSeadragonType; | ||
/** Called whenever driftory navigates to a new frame, whether via clicking, dragging, keys, or API. */ | ||
onFrameChange?: OnFrameChange; | ||
/** Called when the comic has finished initializing. */ | ||
onComicLoad?: OnComicLoad; | ||
/** Called when the user tries to navigate to the next frame in the sequence | ||
* but there are no frames left to navigate to. */ | ||
onNoNext?: OnNoNext; | ||
/** Called when the user tries to navigate to the previous frame in the sequence | ||
* but there are no frames left to navigate to. */ | ||
onNoPrevious?: OnNoPrevious; | ||
prefixUrl?: string; | ||
} | ||
@@ -49,15 +61,25 @@ export default class Driftory { | ||
constructor(args: DriftoryArguments); | ||
_initialize({ container, prefixUrl }: DriftoryArguments): void; | ||
_initialize({ container }: DriftoryArguments): void; | ||
/** Render the comic on screen */ | ||
openComic(unsafeComic: Comic | string): void; | ||
_startComic(): void; | ||
_updateImageVisibility(): void; | ||
/** Determine if the frame navigation controls are currently able to be used to navigate */ | ||
getNavEnabled(): boolean; | ||
/** Enable / Disable frame navigation controls */ | ||
setNavEnabled(flag: boolean): void; | ||
/** Navigate to a specific frame via its index number */ | ||
goToFrame(index: number): void; | ||
/** Get the currently active frame index. This will be whatever frame is in the middle of the | ||
screen. If there is no frame in the middle, it'll be whatever frame the user last had there. */ | ||
getFrameIndex(): number; | ||
_figureFrameIndex(current: boolean): number; | ||
_getHitFrame(point: OpenSeadragon.Point): number; | ||
/** Return the total number of frames found in the comic sequence */ | ||
getFrameCount(): number; | ||
/** Navigate to the next frame in the sequence */ | ||
goToNextFrame(): void; | ||
/** Navigate to the previous frame in the sequence */ | ||
goToPreviousFrame(): void; | ||
} | ||
export {}; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var load_js_1 = require("@dan503/load-js"); | ||
__exportStar(require("./Comic.types"), exports); | ||
__exportStar(require("./openseadragon.types"), exports); | ||
var OpenSeadragon; | ||
@@ -55,3 +43,3 @@ var osdRequest; | ||
var _this = this; | ||
var container = _a.container, prefixUrl = _a.prefixUrl; | ||
var container = _a.container; | ||
this.viewer = | ||
@@ -61,3 +49,2 @@ OpenSeadragon && | ||
element: container, | ||
prefixUrl: prefixUrl, | ||
showNavigationControl: false, | ||
@@ -138,3 +125,3 @@ maxZoomPixelRatio: 10, | ||
}; | ||
// ---------- | ||
/** Render the comic on screen */ | ||
Driftory.prototype.openComic = function (unsafeComic) { | ||
@@ -228,7 +215,7 @@ var _this = this; | ||
}; | ||
// ---------- | ||
/** Determine if the frame navigation controls are currently able to be used to navigate */ | ||
Driftory.prototype.getNavEnabled = function () { | ||
return this.navEnabled; | ||
}; | ||
// ---------- | ||
/** Enable / Disable frame navigation controls */ | ||
Driftory.prototype.setNavEnabled = function (flag) { | ||
@@ -239,3 +226,3 @@ var _a; | ||
}; | ||
// ---------- | ||
/** Navigate to a specific frame via its index number */ | ||
Driftory.prototype.goToFrame = function (index) { | ||
@@ -257,3 +244,4 @@ var _a; | ||
}; | ||
// ---------- | ||
/** Get the currently active frame index. This will be whatever frame is in the middle of the | ||
screen. If there is no frame in the middle, it'll be whatever frame the user last had there. */ | ||
Driftory.prototype.getFrameIndex = function () { | ||
@@ -305,7 +293,7 @@ return this.frameIndex; | ||
}; | ||
// ---------- | ||
/** Return the total number of frames found in the comic sequence */ | ||
Driftory.prototype.getFrameCount = function () { | ||
return this.frames.length; | ||
}; | ||
// ---------- | ||
/** Navigate to the next frame in the sequence */ | ||
Driftory.prototype.goToNextFrame = function () { | ||
@@ -320,3 +308,3 @@ var index = this.getFrameIndex(); | ||
}; | ||
// ---------- | ||
/** Navigate to the previous frame in the sequence */ | ||
Driftory.prototype.goToPreviousFrame = function () { | ||
@@ -323,0 +311,0 @@ var index = this.getFrameIndex(); |
{ | ||
"name": "@driftory/viewer", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A viewer for comics created with https://www.driftory.com/", | ||
@@ -5,0 +5,0 @@ "main": "./dist/driftory.js", |
63076
1756