Skip to content

Commit b3ef3f9

Browse files
KristjanESPERANTObrunob
authored andcommitted
fix(build): simplify UMD global to L.Control.FullScreen
- Add default export alongside named export - Add separate UMD entry point for clean default export - Update README to remove non-functional fullscreenControl option - Update demo to use old simplified syntax Fixes the redundant L.Control.FullScreen.FullScreen introduced in v5.
1 parent fb0792c commit b3ef3f9

File tree

7 files changed

+58
-62
lines changed

7 files changed

+58
-62
lines changed

README.md

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,30 @@ If you want to host the files yourself, you can download them from [npm](https:/
2020
Add the fullscreen control to the map:
2121

2222
```js
23-
let map = new L.Map('map', {
24-
fullscreenControl: true,
25-
fullscreenControlOptions: {
26-
position: 'topleft'
27-
}
28-
});
23+
const map = L.map('map');
24+
25+
map.addControl(new L.Control.FullScreen());
2926
```
3027

31-
If your map has a zoomControl the fullscreen button will be added at the bottom of this one.
28+
If your map has a zoomControl, the fullscreen button will be added at the bottom of it.
3229

33-
If your map doesn't have a zoomControl the fullscreen button will be added to topleft corner of the map (same as the zoomControl).
30+
If your map doesn't have a zoomControl, the fullscreen button will be added to the topleft corner of the map (default position).
3431

3532
If you want to use the plugin on a map embedded in an iframe, don't forget to set `allowfullscreen` attribute on your iframe.
3633

3734
**Option, events and methods**:
3835

3936
```js
4037
// create a fullscreen button and add it to the map
41-
L.control
42-
.fullscreen({
43-
position: 'topleft', // change the position of the button can be topleft, topright, bottomright or bottomleft, default topleft
44-
title: 'Show me the fullscreen !', // change the title of the button, default Full Screen
45-
titleCancel: 'Exit fullscreen mode', // change the title of the button when fullscreen is on, default Exit Full Screen
46-
content: null, // change the content of the button, can be HTML, default null
47-
forceSeparateButton: true, // force separate button to detach from zoom buttons, default false
48-
forcePseudoFullscreen: true, // force use of pseudo full screen even if full screen API is available, default false
49-
fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container
50-
})
51-
.addTo(map);
38+
new L.Control.FullScreen({
39+
position: 'topleft', // change the position of the button can be topleft, topright, bottomright or bottomleft, default topleft
40+
title: 'Show me the fullscreen !', // change the title of the button, default Full Screen
41+
titleCancel: 'Exit fullscreen mode', // change the title of the button when fullscreen is on, default Exit Full Screen
42+
content: null, // change the content of the button, can be HTML, default null
43+
forceSeparateButton: true, // force separate button to detach from zoom buttons, default false
44+
forcePseudoFullscreen: true, // force use of pseudo full screen even if full screen API is available, default false
45+
fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container
46+
}).addTo(map);
5247

5348
// events are fired when entering or exiting fullscreen.
5449
map.on('enterFullscreen', function () {
@@ -115,19 +110,14 @@ To use this plugin with a bundler (Webpack, Vite, etc.):
115110
<link rel="stylesheet" href="node_modules/leaflet.fullscreen/dist/Control.FullScreen.css" />
116111
```
117112

118-
Alternatively, you can use the classic approach with side effects:
113+
Alternatively, you can use the default export:
119114

120115
```js
121-
import L from 'leaflet';
122-
import 'leaflet.fullscreen';
116+
import FullScreen from 'leaflet.fullscreen';
123117
import 'leaflet.fullscreen/dist/Control.FullScreen.css';
124118

125-
const map = new L.Map('map', {
126-
fullscreenControl: true,
127-
fullscreenControlOptions: {
128-
position: 'topleft'
129-
}
130-
});
119+
const map = L.map('map');
120+
map.addControl(new FullScreen());
131121
```
132122

133123
## Contributing

demo/demo.umd.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h3>Script Tags Demo</h3>
6060

6161
// Add fullscreen control
6262
map.addControl(
63-
new L.Control.FullScreen.FullScreen({
63+
new L.Control.FullScreen({
6464
position: 'topleft',
6565
title: 'Show me the fullscreen!',
6666
titleCancel: 'Exit fullscreen mode'

dist/Control.FullScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,4 @@ Map.include({
274274
}
275275
});
276276

277-
export { FullScreen };
277+
export { FullScreen, FullScreen as default };

dist/Control.FullScreen.umd.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66
/*! GENERATED FILE - DO NOT EDIT DIRECTLY. Edit files in src/ and run 'npm run build' */
77
(function (global, factory) {
8-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('leaflet')) :
9-
typeof define === 'function' && define.amd ? define(['exports', 'leaflet'], factory) :
10-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.L = global.L || {}, global.L.Control = global.L.Control || {}, global.L.Control.FullScreen = {}), global.L));
11-
})(this, (function (exports, leaflet) { 'use strict';
8+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('leaflet')) :
9+
typeof define === 'function' && define.amd ? define(['leaflet'], factory) :
10+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.L = global.L || {}, global.L.Control = global.L.Control || {}, global.L.Control.FullScreen = factory(global.L)));
11+
})(this, (function (leaflet) { 'use strict';
1212

1313
if (typeof document === 'undefined') {
1414
console.warn('"window.document" is undefined; leaflet.fullscreen requires this object to access the DOM');
@@ -278,6 +278,6 @@
278278
}
279279
});
280280

281-
exports.FullScreen = FullScreen;
281+
return FullScreen;
282282

283283
}));

rollup.config.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
import { copyFileSync } from 'fs';
22

3-
export default {
4-
input: 'src/Control.FullScreen.js',
5-
external: ['leaflet'],
6-
output: [
7-
{
8-
file: 'dist/Control.FullScreen.js',
9-
format: 'es',
10-
banner: `/*!
3+
const banner = `/*!
114
* leaflet.fullscreen
125
* (c) Bruno B.; MIT License
136
* https://github.com/brunob/leaflet.fullscreen
147
*/
15-
/*! GENERATED FILE - DO NOT EDIT DIRECTLY. Edit files in src/ and run 'npm run build' */`,
8+
/*! GENERATED FILE - DO NOT EDIT DIRECTLY. Edit files in src/ and run 'npm run build' */`;
9+
10+
export default [
11+
// ESM build (supports named and default exports)
12+
{
13+
input: 'src/Control.FullScreen.js',
14+
external: ['leaflet'],
15+
output: {
16+
file: 'dist/Control.FullScreen.js',
17+
format: 'es',
18+
banner,
1619
sourcemap: false
1720
},
18-
{
21+
plugins: [
22+
{
23+
name: 'copy-assets',
24+
buildEnd() {
25+
copyFileSync('src/Control.FullScreen.css', 'dist/Control.FullScreen.css');
26+
}
27+
}
28+
]
29+
},
30+
// UMD build (uses separate entry for clean default export → L.Control.FullScreen)
31+
{
32+
input: 'src/umd-entry.js',
33+
external: ['leaflet'],
34+
output: {
1935
file: 'dist/Control.FullScreen.umd.js',
2036
format: 'umd',
2137
name: 'L.Control.FullScreen',
38+
exports: 'default',
2239
globals: {
2340
leaflet: 'L'
2441
},
25-
banner: `/*!
26-
* leaflet.fullscreen
27-
* (c) Bruno B.; MIT License
28-
* https://github.com/brunob/leaflet.fullscreen
29-
*/
30-
/*! GENERATED FILE - DO NOT EDIT DIRECTLY. Edit files in src/ and run 'npm run build' */`,
42+
banner,
3143
sourcemap: false
3244
}
33-
],
34-
plugins: [
35-
{
36-
name: 'copy-assets',
37-
buildEnd() {
38-
copyFileSync('src/Control.FullScreen.css', 'dist/Control.FullScreen.css');
39-
}
40-
}
41-
]
42-
};
45+
}
46+
];

src/Control.FullScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,5 +268,5 @@ Map.include({
268268
}
269269
});
270270

271-
// Export for ES modules
272271
export { FullScreen };
272+
export default FullScreen;

src/umd-entry.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// UMD entry point - exports only the default for cleaner global (L.Control.FullScreen)
2+
export { default } from './Control.FullScreen.js';

0 commit comments

Comments
 (0)