Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework PNG Icon with SVG and SCSS #97

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
8 changes: 0 additions & 8 deletions Control.FullScreen.css

This file was deleted.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ L.control.fullscreen({
position: 'topleft', // change the position of the button can be topleft, topright, bottomright or bottomleft, default topleft
title: 'Show me the fullscreen !', // change the title of the button, default Full Screen
titleCancel: 'Exit fullscreen mode', // change the title of the button when fullscreen is on, default Exit Full Screen
content: null, // change the content of the button, can be HTML, default null
content: null, // change the content of the button, can be HTML, default '<span class="fullscreen-icon fullscreen-icon-expand"></span>'
forceSeparateButton: true, // force separate button to detach from zoom buttons, default false
forcePseudoFullscreen: true, // force use of pseudo full screen even if full screen API is available, default false
fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container
Expand All @@ -74,3 +74,11 @@ Source code : https://github.com/brunob/leaflet.fullscreen
Downloads : https://github.com/brunob/leaflet.fullscreen/releases

Demo : https://brunob.github.io/leaflet.fullscreen/


LICENSE
-------

MIT

SVG icons from [Font Awesome v5.15.4](https://github.com/FortAwesome/Font-Awesome/releases/tag/5.15.4): [Creative Commons Attribution 4.0](https://fontawesome.com/license/free)
1 change: 1 addition & 0 deletions compress-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dist/Control.FullScreen.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/Control.FullScreen.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/Control.FullScreen.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions expand-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icon-fullscreen-2x.png
Binary file not shown.
Binary file removed icon-fullscreen.png
Binary file not shown.
13 changes: 3 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
<meta charset='utf-8'>
<title>Leaflet.Control.FullScreen Demo</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@latest/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@latest/dist/leaflet.js"></script>
<link rel="stylesheet" href="dist/Control.FullScreen.min.css" />
<script src="dist/Control.FullScreen.min.js"></script>
<style type="text/css">
#map { width: 700px; height: 433px; }
.fullscreen-icon { background-image: url(icon-fullscreen.png); }
.leaflet-retina .fullscreen-icon { background-image: url(icon-fullscreen-2x.png); background-size: 26px 26px; }
/* one selector per rule as explained here : http://www.sitepoint.com/html5-full-screen-api/ */
.leaflet-container:-webkit-full-screen { width: 100% !important; height: 100% !important; z-index: 99999; }
.leaflet-container:-ms-fullscreen { width: 100% !important; height: 100% !important; z-index: 99999; }
.leaflet-container:full-screen { width: 100% !important; height: 100% !important; z-index: 99999; }
.leaflet-container:fullscreen { width: 100% !important; height: 100% !important; z-index: 99999; }
.leaflet-pseudo-fullscreen { position: fixed !important; width: 100% !important; height: 100% !important; top: 0px !important; left: 0px !important; z-index: 99999; }
</style>
<script src="https://unpkg.com/leaflet@latest/dist/leaflet.js"></script>
<script src="Control.FullScreen.js"></script>
</head>
<body>

Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"description": "Simple plugin for Leaflet that adds fullscreen button to your maps.",
"main": "Control.FullScreen.js",
"scripts": {
"test": "eslint --config .eslintrc Control.FullScreen.js"
"test": "eslint --config .eslintrc src/Control.FullScreen.js",
"uglifyjs": "uglifyjs src/Control.FullScreen.js > dist/Control.FullScreen.min.js",
"sass": "sass -s compressed src/Control.FullScreen.scss dist/Control.FullScreen.min.css",
"build": "npm run uglifyjs; npm run sass"
},
"repository": {
"type": "git",
Expand All @@ -17,7 +20,9 @@
"fullscreen"
],
"devDependencies": {
"eslint": "^8.1.0"
"eslint": "^8.1.0",
"sass": "^1.43.5",
"uglify-js": "^3.14.3"
},
"author": "b_b",
"license": "MIT License",
Expand Down
13 changes: 10 additions & 3 deletions Control.FullScreen.js → src/Control.FullScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@
_screenfull: screenfull,

onAdd: function (map) {
var className = 'leaflet-control-zoom-fullscreen', container, content = '';
var className = 'leaflet-control-zoom-fullscreen';
var container;
var content = '<span class="fullscreen-icon fullscreen-icon-expand"></span>';

if (map.zoomControl && !this.options.forceSeparateButton) {
container = map.zoomControl._container;
Expand All @@ -224,14 +226,13 @@

if (this.options.content) {
content = this.options.content;
} else {
className += ' fullscreen-icon';
}

this._createButton(this.options.title, className, content, container, this.toggleFullScreen, this);
this._map.fullscreenControl = this;

this._map.on('enterFullscreen exitFullscreen', this._toggleTitle, this);
this._map.on('enterFullscreen exitFullscreen', this._toggleContent, this);

return container;
},
Expand Down Expand Up @@ -310,6 +311,12 @@
this.link.title = this._map._isFullscreen ? this.options.title : this.options.titleCancel;
},

_toggleContent: function () {
if (!this.options.content) {
this.link.innerHTML = this._map._isFullscreen ? '<span class="fullscreen-icon fullscreen-icon-expand"></span>': '<span class="fullscreen-icon fullscreen-icon-compress"></span>';
}
},

_handleFullscreenChange: function () {
var map = this._map;
map.invalidateSize();
Expand Down
60 changes: 60 additions & 0 deletions src/Control.FullScreen.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
a.leaflet-control-zoom-fullscreen {
cursor: pointer;

.fullscreen-icon {
display: inline-block;
width: 16px;
height: 16px;
margin: 7px;
background-color: black;
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-position: center;
mask-position: center;
}

.fullscreen-icon-expand {
-webkit-mask-image: url('../expand-solid.svg');
mask-image: url('../expand-solid.svg');
}

.fullscreen-icon-compress {
-webkit-mask-image: url('../compress-solid.svg');
mask-image: url('../compress-solid.svg');
}
}

.leaflet-container {
&:-webkit-full-screen {
width: 100% !important;
height: 100% !important;
z-index: 99999;
}

&:-ms-fullscreen {
width: 100% !important;
height: 100% !important;
z-index: 99999;
}

&:full-screen {
width: 100% !important;
height: 100% !important;
z-index: 99999;
}

&:fullscreen {
width: 100% !important;
height: 100% !important;
z-index: 99999;
}
}

.leaflet-pseudo-fullscreen {
position: fixed !important;
width: 100% !important;
height: 100% !important;
top: 0px !important;
left: 0px !important;
z-index: 99999;
}