Skip to content
Merged
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
24 changes: 7 additions & 17 deletions public/main/template/default/exercise/submit.js.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,9 @@
$(".droppable")
);

// Auto-detect matching questions and init jsPlumb per question (early init)
(function autoInitMatching() {
// We infer question ids from classes like 'window{qid}_question'
var qids = {};
$('[class]').each(function () {
var classes = (this.className || '').toString().split(/\s+/);
classes.forEach(function (c) {
var m = c.match(/^window(\d+)_question$/);
if (m) { qids[m[1]] = true; }
});
});
Object.keys(qids).forEach(function (qid) {
MatchingDraggable.init(qid);
});
})();
// Use the layout-aware initializer so endpoints are placed
// only when the question area has its final size.
initMatchingWithRetry();
});

/* -----------------------------
Expand All @@ -283,7 +271,7 @@
* Triggers: jsPlumb.ready, window.load, BFCache pageshow.
* Also cleans up instances on pagehide.
*/
function initMatchingWithRetry(maxTries = 12, delay = 80) {
function initMatchingWithRetry(maxTries = 40, delay = 100) {
let tries = 0;

function ready() {
Expand Down Expand Up @@ -323,8 +311,10 @@
try { MatchingDraggable.init(qid); } catch (e) {}
});

// Final repaint in next tick (fonts/scroll may settle)
// Extra repaints to cover slow layouts (tests tool, fonts, etc.)
setTimeout(repaintAllJsPlumbInstances, 0);
setTimeout(repaintAllJsPlumbInstances, 300);
setTimeout(repaintAllJsPlumbInstances, 800);
}

ready();
Expand Down
Loading