Skip to content

Commit

Permalink
Add resize event (and throttle it a bit)
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed May 22, 2024
1 parent 1bd8e10 commit 6246f26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions resources/views/overview/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,16 @@ function grab_data(id, data_type) {
}
// make sure gridster stays disabled when the window is resized
var resizeTrigger = null;
addEvent(window, "resize", function(event) {
// emit resize event, but only once every 100ms
if (resizeTrigger === null) {
resizeTrigger = setTimeout(() => {
resizeTrigger = null;
$('.widget_body').children().first().trigger('resize');
}, 100);
}
setTimeout(function(){
if(!gridster_state) {
gridster.disable();
Expand Down
4 changes: 4 additions & 0 deletions resources/views/widgets/worldmap.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ function populate_markers(map) {
});
}
$('#leaflet-map-{{ $id }}').on('resize', function (event) {
get_map(map_id).invalidateSize();
})
$('#leaflet-map-{{ $id }}').on('refresh', function (event) {
var map = get_map(map_id);
map.invalidateSize();
Expand Down

0 comments on commit 6246f26

Please sign in to comment.