pMovidea made. - I just wrote this in 2021-07-16Movidea Development Diary. - > I have a feeling that Movidea's recent development is diary style like this page, but not like pRegroup or pKeicho, because "the structure may be generated after the fact".
In the principle of trying something that makes you uneasy as soon as possible, next time you should try to select a range of items against the DOM.
It seems useless to recalculate the bounding box when there is no content update, but caching the bounding box value and recalculating it appropriately is also "introducing an extra state", so we should first calculate it naively and cover it with a test, then measure it and cache it only if it is slow. I think we should put in a system to cache only if it is slow.
I was able to do it.
Create test cases
test.ts
cy.get("#canvas").trigger("mousedown", 150, 150);
cy.get("#canvas").trigger("mouseup", 450, 450);
cy.movidea((m) => {
cy.wrap(m.getGlobal().selected_items).should("to.deep.equal", [
"0,0",
"0,1",
"1,0",
"1,1",
]);
});
cy.get("#canvas").trigger("mousedown", 250, 250);
cy.get("#canvas").trigger("mouseup", 150, 150);
cy.movidea((m) => {
cy.wrap(m.getGlobal().selected_items).should("to.deep.equal", ["0,0"]);
});
Can we make a custom command to cy.movidea((m) => {cy.wrap(m.getGlobal().selected_items).should("to.deep.equal"?
to.deep.equal should be to.eql.index.ts
Cypress.Commands.add("getGlobal", (callback: (g: State) => unknown) => {
return cy.movidea((movidea) => {
return cy.wrap(callback(movidea.getGlobal()));
});
});
test.ts
cy.get("#canvas").trigger("mousedown", 250, 250);
cy.get("#canvas").trigger("mouseup", 150, 150);
cy.getGlobal((g) => g.selected_items).should("to.eql", ["0,0"]);
Well, I guess that's about it.
Can you move the selection?
Put the DOM of the selected item in the selection div at the time of either mouse down in the selection or the completion of the selection.
This page is auto-translated from /nishio/2021-07-19Movidea開発日記 using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.