Comments (5)
What do you mean by dynamic?
In general you need to override the width
and max-width
CSS properties on the .leaflet-sidebar
selector.
As the sidebar style is responsive, you'd need to override it for multiple media queries.
This is the default style you'd need to override:
@media (min-width: 768px) and (max-width: 991px) {
.leaflet-sidebar {
width: 305px;
max-width: 305px; } }
@media (min-width: 992px) and (max-width: 1199px) {
.leaflet-sidebar {
width: 390px;
max-width: 390px; } }
@media (min-width: 1200px) {
.leaflet-sidebar {
width: 460px;
max-width: 460px; } }
from leaflet-sidebar-v2.
If you want to change the width when a tab was clicked, you can register an event and adjust the sidebar style in JS:
sidebar.on('content', function (e) {
const sidebarElement = document.querySelector('.leaflet-sidebar')
switch (e.id) {
case 'smalltab': // your tab IDs
sidebarElement.style.width = '200px'
sidebarElement.style.maxWidth = '200px'
break
case 'largetab':
sidebarElement.style.width = '600px'
sidebarElement.style.maxWidth = '600px'
break
}
})
This does not respect responsiveness however.
from leaflet-sidebar-v2.
Hey,
when I do this, the tabs won't close anymore. Any idea how to solve that?
from leaflet-sidebar-v2.
@Janphr
With the approach outlined above, you need to remove the style again on the closing
event.
Maybe a better approach would be to write CSS classes for each tab with the desired width, and toggle the classes in the content
event. The following shows what I mean but is untested
.leaflet-sidebar:not(.collapsed).mypanel {
width: 600px;
max-width: 600px;
}
sidebar.on('content', e => {
const sidebarElement = document.querySelector('.leaflet-sidebar')
sidebarElement.classList.remove('all', 'the', 'panel ids', 'you', 'want', 'to', 'handle', 'here')
sidebarElement.classList.add(e.id)
})
from leaflet-sidebar-v2.
Thanks for the quick response!
Just added:
if (L.DomUtil.hasClass(this, 'active')) {
let sidebar = document.querySelector('.leaflet-sidebar')
sidebar.style.width = 40 + 'px'
sidebar.style.maxWidth = 40 + 'px'
this._sidebar.close();
to the onTabClick function, which works fine.
*Just no smooth transition anymore, so I'll check out your solution
from leaflet-sidebar-v2.
Related Issues (20)
- vue js wrapper HOT 1
- is there a react component availabe? thanks advanced HOT 2
- Can't refresh content HOT 1
- Sidebar on right side causes attribution shift HOT 1
- Is there a way to use JS inside a pane HOT 1
- IE compatibility HOT 2
- fa-bars do not consider top margin. Is it possible to change in the css file? HOT 1
- Allow determining whether sidebar is currently open or closed.
- can you give this library for react version ? HOT 1
- How to use in React? HOT 1
- Allow deep links to tabs
- Place the .leaflet-sidebar-tabs at the bottom horizontally rather than vertically on the left or on the right
- I can't un-insert the checkboxes in the panel HOT 1
- How to update content dynamic
- addUser() function not working. HOT 1
- Icons go invisible after clicking between panels.
- Remove Github link
- react-leaflet-sidebar-v2 hook
- is it possible to remove the tabs pane when we have only one panel
- Open sidebar pane on tooltip click?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet-sidebar-v2.