Skip to content

Commit

Permalink
Smoother slider
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Dupuy <[email protected]>
  • Loading branch information
flo-dup committed Dec 12, 2024
1 parent 91031a5 commit 3637cbd
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions demo/src/diagram-viewers/add-diagrams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ export const addNadToDemo = () => {
flowsSlider.min = '1';
flowsSlider.max = '20';
flowsSlider.value = '1';
flowsSlider.style.width = '99%';
flowsSlider.setAttribute('list', 'flowsDatalist');
flowsSlider.step = 'any';
flowsSlider.style.width = '97%';
flowsSlider.style.display = 'flex';
flowsSlider.style.justifyContent = 'space-between';
flowsSlider.style.padding = '0 5px';
flowsSlider.addEventListener('input', () => {
const flows =
'[{"branchId": "NGEN_NHV1", "side": 1, "p": ' +
Expand All @@ -93,31 +96,7 @@ export const addNadToDemo = () => {
nadViewer.setJsonFlows(flows);
});

const flowsDatalist = document.createElement('datalist');
flowsDatalist.id = 'flowsDatalist';
for (let index = 1; index <= 20; index++) {
const flowsOption = document.createElement('option');
flowsOption.value = index.toString();
flowsDatalist.appendChild(flowsOption);
}

const flowsDiv = document.createElement('div');
for (let index = 1; index <= 20; index++) {
const flowsSpan = document.createElement('span');
flowsSpan.innerHTML = index.toString();
flowsDiv.appendChild(flowsSpan);
}
flowsDiv.style.width = '98%';
flowsDiv.style.display = 'flex';
flowsDiv.style.justifyContent = 'space-between';
flowsDiv.style.padding = '0 5px';
flowsDiv.style.fontSize = '12px';

const updateFlowsDiv = document.createElement('div');
updateFlowsDiv.appendChild(flowsSlider);
updateFlowsDiv.appendChild(flowsDatalist);

document.getElementById('svg-container-nad')?.appendChild(updateFlowsDiv);
document.getElementById('svg-container-nad')?.appendChild(flowsSlider);
});

fetch(NadSvgExample)
Expand Down

0 comments on commit 3637cbd

Please sign in to comment.