mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-29 16:45:13 +02:00
use element.clientWidth for calcing cols
This commit is contained in:
parent
d08427cfde
commit
f29af205c1
@ -83,7 +83,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, inject, watch, onMounted, computed, onBeforeUnmount } from 'vue';
|
||||
import { ref, inject, watch, onMounted, computed, onBeforeUnmount, onUpdated } from 'vue';
|
||||
import Table from './Table.vue';
|
||||
import { clipboardInjectionKey, notificationsInjectionKey, settingsInjectionKey } from '../keys';
|
||||
import LoadingSpinner from './LoadingSpinner.vue';
|
||||
@ -247,13 +247,13 @@ export default {
|
||||
}
|
||||
|
||||
const getCols = () => {
|
||||
const gridRect = gridRef.value?.getBoundingClientRect();
|
||||
if (!gridRect)
|
||||
const gridWidth = gridRef.value?.clientWidth;
|
||||
if (!gridWidth)
|
||||
return cols.value = 1;
|
||||
const entryWidth = settings.directoryView?.gridEntrySize;
|
||||
if (!entryWidth)
|
||||
return cols.value = 1;
|
||||
return cols.value = Math.floor(gridRect.width / entryWidth);
|
||||
return cols.value = Math.floor(gridWidth / entryWidth);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@ -262,6 +262,8 @@ export default {
|
||||
window.addEventListener('resize', getCols);
|
||||
});
|
||||
|
||||
onUpdated(getCols);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('resize', getCols);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user