From f2ecc1803f3ea294a0c6b7915b61348ed0395b26 Mon Sep 17 00:00:00 2001 From: Marcin Zelent Date: Wed, 16 Nov 2022 15:16:38 +0100 Subject: Remade and extended the app using React --- src/types/geojson-bounds.d.ts | 33 ++++++++++++ src/types/photoswipe-lightbox.d.ts | 104 +++++++++++++++++++++++++++++++++++++ src/types/types.d.ts | 14 +++++ 3 files changed, 151 insertions(+) create mode 100644 src/types/geojson-bounds.d.ts create mode 100644 src/types/photoswipe-lightbox.d.ts create mode 100644 src/types/types.d.ts (limited to 'src/types') diff --git a/src/types/geojson-bounds.d.ts b/src/types/geojson-bounds.d.ts new file mode 100644 index 0000000..99eb4a0 --- /dev/null +++ b/src/types/geojson-bounds.d.ts @@ -0,0 +1,33 @@ +declare module 'geojson-bounds' { + import geojson from 'geojson'; + + /** + * Returns an array of coordinates in the order [West, South, East, North] that represents the extent of the provided feature or geometry + */ + export function extent(geojson: geojson.GeoJSON): [number, number, number, number]; + + /** + * Returns a GeoJSON Feature polygon that repesents the bounding box of the provided feature or geometry + */ + export function envelope(geojson: geojson.GeoJSON): geojson.Feature; + + /** + * Returns the western-most longitude of the provided feature or geometry + */ + export function xMin(geojson: geojson.GeoJSON): number; + + /** + * Returns the eastern-most longitude of the provided feature or geometry + */ + export function xMax(geojson: geojson.GeoJSON): number; + + /** + * Returns the southern-most latitude of the provided feature or geometry + */ + export function yMin(geojson: geojson.GeoJSON): number; + + /** + * Returns the northern-most latitude of the provided feature or geometry + */ + export function yMax(geojson: geojson.GeoJSON): number; +} diff --git a/src/types/photoswipe-lightbox.d.ts b/src/types/photoswipe-lightbox.d.ts new file mode 100644 index 0000000..d8847cf --- /dev/null +++ b/src/types/photoswipe-lightbox.d.ts @@ -0,0 +1,104 @@ +declare module 'photoswipe/lightbox' { + import PhotoSwipeBase from 'photoswipe/dist/types/core/base'; + + export default PhotoSwipeLightbox; + /** + * + */ + export type Type = import('photoswipe/dist/types/types').Type; + export type PhotoSwipe = import('photoswipe/dist/types/photoswipe').default; + export type PhotoSwipeOptions = import('photoswipe/dist/types/photoswipe').PhotoSwipeOptions; + export type DataSource = import('photoswipe/dist/types/photoswipe').DataSource; + export type Content = import('photoswipe/dist/types/slide/content').default; + export type PhotoSwipeEventsMap = import('photoswipe/dist/types/core/eventable').PhotoSwipeEventsMap; + export type PhotoSwipeFiltersMap = import('photoswipe/dist/types/core/eventable').PhotoSwipeFiltersMap; + /** + * + */ + export type EventCallback = import('photoswipe/dist/types/core/eventable').EventCallback; + /** + * @template T + * @typedef {import('../types.js').Type} Type + */ + /** @typedef {import('photoswipe/dist/types/photoswipe').default} PhotoSwipe */ + /** @typedef {import('photoswipe/dist/types/photoswipe').PhotoSwipeOptions} PhotoSwipeOptions */ + /** @typedef {import('photoswipe/dist/types/photoswipe').DataSource} DataSource */ + /** @typedef {import('photoswipe/dist/types/slide/content').default} Content */ + /** @typedef {import('photoswipe/dist/types/core/eventable').PhotoSwipeEventsMap} PhotoSwipeEventsMap */ + /** @typedef {import('photoswipe/dist/types/core/eventable').PhotoSwipeFiltersMap} PhotoSwipeFiltersMap */ + /** + * @template T + * @typedef {import('photoswipe/dist/types/core/eventable').EventCallback} EventCallback + */ + /** + * PhotoSwipe Lightbox + * + * - If user has unsupported browser it falls back to default browser action (just opens URL) + * - Binds click event to links that should open PhotoSwipe + * - parses DOM strcture for PhotoSwipe (retrieves large image URLs and sizes) + * - Initializes PhotoSwipe + * + * + * Loader options use the same object as PhotoSwipe, and supports such options: + * + * gallery - Element | Element[] | NodeList | string selector for the gallery element + * children - Element | Element[] | NodeList | string selector for the gallery children + * + */ + declare class PhotoSwipeLightbox extends PhotoSwipeBase { + /** + * @param {PhotoSwipeOptions} options + */ + constructor(options: PhotoSwipeOptions); + _uid: number; + /** + * Initialize lightbox, should be called only once. + * It's not included in the main constructor, so you may bind events before it. + */ + init(): void; + /** + * @param {MouseEvent} e + */ + onThumbnailsClick(e: MouseEvent): void; + /** + * Get index of gallery item that was clicked. + * + * @param {MouseEvent} e click event + */ + getClickedIndex(e: MouseEvent): number; + /** + * Load and open PhotoSwipe + * + * @param {number} index + * @param {DataSource=} dataSource + * @param {{ x?: number; y?: number }} [initialPoint] + */ + loadAndOpen( + index: number, + dataSource?: DataSource | undefined, + initialPoint?: { + x?: number; + y?: number; + }, + ): boolean; + shouldOpen: boolean; + /** + * Load the main module and the slide content by index + * + * @param {number} index + * @param {DataSource=} dataSource + */ + preload(index: number, dataSource?: DataSource | undefined): void; + _preloadedContent: import('photoswipe/dist/types/slide/content').default; + /** + * @private + * @param {Type | { default: Type }} module + * @param {number} uid + */ + private readonly _openPhotoswipe; + /** + * Unbinds all events, closes PhotoSwipe if it's open. + */ + destroy(): void; + } +} diff --git a/src/types/types.d.ts b/src/types/types.d.ts new file mode 100644 index 0000000..ebf6fd5 --- /dev/null +++ b/src/types/types.d.ts @@ -0,0 +1,14 @@ +declare global { + interface Document { + webkitExitFullscreen?: () => Promise; + webkitFullscreenElement?: Element; + } + + interface HTMLElement { + webkitRequestFullscreen?: () => Promise; + } +} + +declare module 'exif-reader'; +declare module 'photoswipe-dynamic-caption-plugin'; +declare module 'photoswipe-video-plugin'; -- cgit v1.2.3