@types/leaflet.fullscreen Update definitions to 1.6. Add missing fields to MapOptions and Map (#43180)

This commit is contained in:
Dan Manastireanu 2020-03-23 17:45:49 +02:00 committed by GitHub
parent db21a0f0c0
commit 0928d72fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 2 deletions

View File

@ -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 <https://github.com/wcomartin>
// Dan Manastireanu <https://github.com/danmana>
// 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;
}
}

View File

@ -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: '<i class="fa fa-arrows-alt"></i>',
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();