From 0928d72fb0e5cf9d20f4fe5ff46c9ed5e8094960 Mon Sep 17 00:00:00 2001 From: Dan Manastireanu <498419+danmana@users.noreply.github.com> Date: Mon, 23 Mar 2020 17:45:49 +0200 Subject: [PATCH] @types/leaflet.fullscreen Update definitions to 1.6. Add missing fields to MapOptions and Map (#43180) --- types/leaflet.fullscreen/index.d.ts | 13 +++++++++- .../leaflet.fullscreen-tests.ts | 25 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/types/leaflet.fullscreen/index.d.ts b/types/leaflet.fullscreen/index.d.ts index 79ab81114b..bf1f264240 100644 --- a/types/leaflet.fullscreen/index.d.ts +++ b/types/leaflet.fullscreen/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for Leaflet.fullscreen 1.3 +// Type definitions for Leaflet.fullscreen 1.6 // Project: https://github.com/brunob/leaflet.fullscreen // Definitions by: William Comartin +// Dan Manastireanu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -21,6 +22,7 @@ declare module 'leaflet' { forceSeparateButton?: boolean; forcePseudoFullscreen?: boolean; pseudoFullscreen?: boolean; + fullscreenElement?: false | HTMLElement; } } @@ -30,4 +32,13 @@ declare module 'leaflet' { */ function fullscreen(options?: Control.FullscreenOptions): Control.Fullscreen; } + + interface MapOptions { + fullscreenControl?: boolean; + fullscreenControlOptions?: Control.FullscreenOptions; + } + + interface Map { + toggleFullScreen(): void; + } } diff --git a/types/leaflet.fullscreen/leaflet.fullscreen-tests.ts b/types/leaflet.fullscreen/leaflet.fullscreen-tests.ts index e118e5b233..79df574389 100644 --- a/types/leaflet.fullscreen/leaflet.fullscreen-tests.ts +++ b/types/leaflet.fullscreen/leaflet.fullscreen-tests.ts @@ -9,7 +9,8 @@ const icon: L.Control.Fullscreen = L.control.fullscreen({ title: 'Full Screen', titleCancel: 'Exit Full Screen', forceSeparateButton: false, - forcePseudoFullscreen: false + forcePseudoFullscreen: false, + fullscreenElement: false }); icon.addTo(map); @@ -20,3 +21,25 @@ L.control.fullscreen({ content: '', forceSeparateButton: true, }).addTo(map); + +// MapOptions initHook +L.map('map-container', { + fullscreenControl: true, + fullscreenControlOptions: { + position: 'topleft', + title: 'Full Screen', + titleCancel: 'Exit Full Screen', + forceSeparateButton: false, + forcePseudoFullscreen: false, + fullscreenElement: false + } +}); + +// configurable fullscreen element +const htmlElement = map.getContainer(); +L.control.fullscreen({ + fullscreenElement: htmlElement +}); + +// you can also toggle fullscreen from map object +map.toggleFullScreen();