From ff7c617778f0f0682e7c5a56bd94941286637a24 Mon Sep 17 00:00:00 2001 From: TomasKulhanek Date: Tue, 22 Jun 2021 13:10:47 +0200 Subject: [PATCH] UPDATE creative-connections/ Bodylight-Scenarios/#53 fmi listen to 'input' event by default --- docs/usersguide/fmi.md | 4 +++- docs/usersguide/pdb.md | 1 + src/elements/fmi.js | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/usersguide/fmi.md b/docs/usersguide/fmi.md index 0434ead..1135386 100644 --- a/docs/usersguide/fmi.md +++ b/docs/usersguide/fmi.md @@ -8,11 +8,13 @@ * `guid` guid as it appears in FMU model description * `valuereferences` references to variables, custom event 'fmidata' with `event.detail` set to `{time: number , data:[number,...]}` where time is timepoint of the current simulation step and data is array of values in same order as in valuereferences - * `inputs` id of component, value reference, optional nominator,denominator to normalize `value * nominator / denominator` all delimited by coma`,`, other inputs delimited by semicolon `;` e.g. `inputs="id1,1677323,1,60;id2,16725364"` cause that the value from id1 will be converted `x= valueid1 *1/60` and value from id2 `x = valueid2*1/1` ; + * `inputs` id of component, value reference, optional nominator,denominator to normalize `value * nominator / denominator` all delimited by coma`,`, other inputs delimited by semicolon `;` e.g. `inputs="id1,1677323,1,60;id2,16725364"` cause that the value from id1 will be converted `x= valueid1 *1/60` and value from id2 `x = valueid2*1/1` ; + * `eventlisten` event to listen on input elements - default "input" event - change is fired hen e.g. cursor is moved. You may change it to "change" - it is fired only when user drops the vlaue/ confirms the change. * `otherinputs` ids of components which triggers custom event 'fmiinput', it is expected that in event.detail contains this structure `{ valuereference: number, value: number }` * `showcontrols` - default `true`, shows/hides basic control buttons to start/stop/restart simulation * `fpslimit` - 1-60, default 60 = unlimited (default FPS allowed by browser). This attribute will limit the frames per second + and for values <60 will introduce some artificial delay to reduce framerate to the desired value. The limiting range is also available in UI. Example: diff --git a/docs/usersguide/pdb.md b/docs/usersguide/pdb.md index 0babfad..0111f5f 100644 --- a/docs/usersguide/pdb.md +++ b/docs/usersguide/pdb.md @@ -20,6 +20,7 @@ To visualize molecule in PDB database * width, height - set width and height of canvas to render pdbe component, include unit in css, e.g. '300px' or '100%' * visual-style - set visual style - "cartoon","ball-and-stick",... * show-ions - comma separated labels of ions to be shown differently using gaussian-surface - big balls +* custom-data-url - sets url to custom pdb file The component renders by default window with width 100% and height 400px and set's automatic spin of the molecule for 60s. diff --git a/src/elements/fmi.js b/src/elements/fmi.js index 679f77c..a7834f1 100644 --- a/src/elements/fmi.js +++ b/src/elements/fmi.js @@ -17,6 +17,7 @@ export class Fmi { @bindable fpslimit = 60; @bindable showtime = false; @bindable showtimemultiply = 1; + @bindable eventlisten = 'input';//input==continuous/change==when user drops the value cosimulation=1; stepSize=0.01;//0.0078125; @@ -92,7 +93,8 @@ export class Fmi { this.inputreferences[myinputs[0]] = {ref: myinputs[1], numerator: numerator, denominator: denominator, addconst: addconst, fixed: fixedsignature}; //first is id second is reference //register change event - the alteration is commited let dependentEl = document.getElementById(myinputs[0]); - if (dependentEl) dependentEl.addEventListener('change', this.handleValueChange); + //now register 'change' event or eventlisten + if (dependentEl) dependentEl.addEventListener(this.eventlisten, this.handleValueChange); else console.warn('cannot register changes for non-existing element id:', myinputs[0]); console.log('registering input, ref, num,den,add,fixed', myinputs[0], myinputs[1], numerator, denominator, addconst, fixedsignature); }