-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Subject
i'm trying to build a dashboard in a vue3 template on the base of the vue3js.html example. page loads w/o erros.
but as soon i invoke the addWidget method, the script hangs.
environment
- gridstack 3.3.0 using html5
- vue 3.0.0
- vue-router 4.0
tested on
- firefox 78.6.0esr
- MS Edge Version 88.0.705.74
code
<template>
<h1>Dashboard</h1>
<button @click="addNewWidget">add Widget</button>
<div class="grid-stack"></div>
</template>
<script>
const api = require("../js/api-connector");
import { GridStack } from 'gridstack'; // $ optional if you depend on it, to be removed in 3.x
import 'gridstack/dist/gridstack.css';
// THEN to get HTML5 drag&drop
import 'gridstack/dist/h5/gridstack-dd-native';
export default {
name: "Dashboard",
data () {
return {
//grid
grid: undefined,
count: 0,
info: ""
}
},
items: [
{ x: 2, y: 1, h: 2 },
{ x: 2, y: 4, w: 3},
{ x: 4, y: 2},
{ x: 3, y: 1, h: 2 },
{ x: 0, y: 6, w: 2, h: 2 }
],
watch: {
/**
* Clear the info text after a two second timeout. Clears previous timeout first.
*/
info: function (newVal, oldVal) {
if (newVal.length === 0) return;
window.clearTimeout(this.timerId);
this.timerId = window.setTimeout(() => {
this.info = "";
}, 2000);
}
},
mounted() {
this.grid = GridStack.init({ float: true, cellHeight: '70px', minRow: 1 });
this.grid.on("dragstop", (event, element) => {
const node = element.gridstackNode;
this.info = `you just dragged node #${node.id} to ${node.x},${node.y} – good job!`;
});
},
methods: {
addNewWidget() {
const node = this.$options.items[this.count] || {
x: Math.round(12 * Math.random()),
y: Math.round(5 * Math.random()),
w: Math.round(1 + 3 * Math.random()),
h: Math.round(1 + 3 * Math.random()),
};
node.id = node.content = String(this.count++);
this.grid.addWidget(node);
}
}
}
</script>what happens:
the script hangs up. firefox issues that the scripts slows down the browser and gives the choice of either stop the script or wait for it to finish. if you stop it the following appears in the console:
Script terminated by timeout at:
get@webpack-internal:///./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js:257:48
_fixCollisions/hasLocked<@webpack-internal:///./node_modules/gridstack/dist/gridstack-engine.js:50:54
_fixCollisions@webpack-internal:///./node_modules/gridstack/dist/gridstack-engine.js:50:44
moveNode@webpack-internal:///./node_modules/gridstack/dist/gridstack-engine.js:474:14
_fixCollisions@webpack-internal:///./node_modules/gridstack/dist/gridstack-engine.js:64:30
addNode@webpack-internal:///./node_modules/gridstack/dist/gridstack-engine.js:315:14
_prepareElement@webpack-internal:///./node_modules/gridstack/dist/gridstack.js:1098:28
addWidget@webpack-internal:///./node_modules/gridstack/dist/gridstack.js:335:14
addNewWidget@webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader-v16/dist/index.js?!./src/views/Dashboard.vue?vue&type=script&lang=js:190:17
render</_cache[2]@webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/vue-loader-v16/dist/templateLoader.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader-v16/dist/index.js?!./src/views/Dashboard.vue?vue&type=template&id=22ba47ca&scoped=true:54:61
callWithErrorHandling@webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:275:22
callWithAsyncErrorHandling@webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:284:42
invoker@webpack-internal:///./node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js:512:97
Since there is no error until i try to add a new widget i assume that gridstack is imported correctly into the template. Any hints or suggestions to fix that?
best regards
m