skytnt commited on
Commit
684555c
1 Parent(s): 35fbbe7

scroll bar

Browse files
Files changed (1) hide show
  1. javascript/app.js +13 -8
javascript/app.js CHANGED
@@ -116,6 +116,7 @@ class MidiVisualizer extends HTMLElement{
116
  for (let i=0;i<16;i++){
117
  this.patches.push([[0,0]])
118
  }
 
119
  this.trackList = null
120
  this.pianoRoll = null;
121
  this.svg = null;
@@ -124,6 +125,10 @@ class MidiVisualizer extends HTMLElement{
124
  noteHeight : 4,
125
  beatWidth: 32
126
  }
 
 
 
 
127
  this.timePreBeat = 16
128
  this.svgWidth = 0;
129
  this.t1 = 0;
@@ -142,18 +147,16 @@ class MidiVisualizer extends HTMLElement{
142
  this.innerHTML=''
143
  const shadow = this.attachShadow({mode: 'open'});
144
  const style = document.createElement("style");
 
145
  const container = document.createElement('div');
146
  container.style.display="flex";
147
- container.style.height=`${this.config.noteHeight*128}px`;
148
  const trackListContainer = document.createElement('div');
149
  trackListContainer.style.width = "260px";
150
  trackListContainer.style.minWidth = "260px";
151
  trackListContainer.style.height = "100%";
152
  trackListContainer.style.display="flex";
153
  trackListContainer.style.flexDirection="column";
154
- if (isMobile()){
155
- trackListContainer.style.display = "none";
156
- }
157
  const trackList = document.createElement('div');
158
  trackList.style.width = "100%";
159
  trackList.style.height = "100%";
@@ -171,7 +174,6 @@ class MidiVisualizer extends HTMLElement{
171
  allTrackBtn.textContent = "All";
172
  allTrackBtn.style.width = "50%";
173
  allTrackBtn.style.height = "100%";
174
- allTrackBtn.style.backgroundColor = "transparent";
175
  allTrackBtn.style.border = "none";
176
  allTrackBtn.style.cursor = 'pointer';
177
  let self = this;
@@ -184,7 +186,6 @@ class MidiVisualizer extends HTMLElement{
184
  noneTrackBtn.textContent = "None";
185
  noneTrackBtn.style.width = "50%";
186
  noneTrackBtn.style.height = "100%";
187
- noneTrackBtn.style.backgroundColor = "transparent";
188
  noneTrackBtn.style.border = "none";
189
  noneTrackBtn.style.cursor = 'pointer';
190
  noneTrackBtn.onclick = function (){
@@ -193,7 +194,6 @@ class MidiVisualizer extends HTMLElement{
193
  });
194
  };
195
  const pianoRoll = document.createElement('div');
196
- style.textContent = ".note.active {stroke: black;stroke-width: 0.75;stroke-opacity: 0.75;}";
197
  pianoRoll.style.overflowX= "scroll";
198
  pianoRoll.style.flexGrow="1";
199
  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
@@ -201,8 +201,12 @@ class MidiVisualizer extends HTMLElement{
201
  svg.style.width = `${this.svgWidth}px`;
202
  const timeLine = document.createElementNS('http://www.w3.org/2000/svg', 'line');
203
  timeLine.style.stroke = "green"
204
- timeLine.style.strokeWidth = 2;
205
 
 
 
 
 
206
  shadow.appendChild(style)
207
  shadow.appendChild(container);
208
  container.appendChild(trackListContainer);
@@ -213,6 +217,7 @@ class MidiVisualizer extends HTMLElement{
213
  container.appendChild(pianoRoll);
214
  pianoRoll.appendChild(svg);
215
  svg.appendChild(timeLine)
 
216
  this.trackList = trackList;
217
  this.pianoRoll = pianoRoll;
218
  this.svg = svg;
 
116
  for (let i=0;i<16;i++){
117
  this.patches.push([[0,0]])
118
  }
119
+ this.container = null;
120
  this.trackList = null
121
  this.pianoRoll = null;
122
  this.svg = null;
 
125
  noteHeight : 4,
126
  beatWidth: 32
127
  }
128
+ if (isMobile()){
129
+ this.config.noteHeight = 1;
130
+ this.config.beatWidth = 16;
131
+ }
132
  this.timePreBeat = 16
133
  this.svgWidth = 0;
134
  this.t1 = 0;
 
147
  this.innerHTML=''
148
  const shadow = this.attachShadow({mode: 'open'});
149
  const style = document.createElement("style");
150
+ style.textContent = ".note.active {stroke: black;stroke-width: 0.75;stroke-opacity: 0.75;}";
151
  const container = document.createElement('div');
152
  container.style.display="flex";
153
+ container.style.height=`${this.config.noteHeight*128 + 25}px`;
154
  const trackListContainer = document.createElement('div');
155
  trackListContainer.style.width = "260px";
156
  trackListContainer.style.minWidth = "260px";
157
  trackListContainer.style.height = "100%";
158
  trackListContainer.style.display="flex";
159
  trackListContainer.style.flexDirection="column";
 
 
 
160
  const trackList = document.createElement('div');
161
  trackList.style.width = "100%";
162
  trackList.style.height = "100%";
 
174
  allTrackBtn.textContent = "All";
175
  allTrackBtn.style.width = "50%";
176
  allTrackBtn.style.height = "100%";
 
177
  allTrackBtn.style.border = "none";
178
  allTrackBtn.style.cursor = 'pointer';
179
  let self = this;
 
186
  noneTrackBtn.textContent = "None";
187
  noneTrackBtn.style.width = "50%";
188
  noneTrackBtn.style.height = "100%";
 
189
  noneTrackBtn.style.border = "none";
190
  noneTrackBtn.style.cursor = 'pointer';
191
  noneTrackBtn.onclick = function (){
 
194
  });
195
  };
196
  const pianoRoll = document.createElement('div');
 
197
  pianoRoll.style.overflowX= "scroll";
198
  pianoRoll.style.flexGrow="1";
199
  const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
 
201
  svg.style.width = `${this.svgWidth}px`;
202
  const timeLine = document.createElementNS('http://www.w3.org/2000/svg', 'line');
203
  timeLine.style.stroke = "green"
204
+ timeLine.style.strokeWidth = "2";
205
 
206
+ if (isMobile()){
207
+ trackListContainer.style.display = "none";
208
+ timeLine.style.strokeWidth = "1";
209
+ }
210
  shadow.appendChild(style)
211
  shadow.appendChild(container);
212
  container.appendChild(trackListContainer);
 
217
  container.appendChild(pianoRoll);
218
  pianoRoll.appendChild(svg);
219
  svg.appendChild(timeLine)
220
+ this.container = container;
221
  this.trackList = trackList;
222
  this.pianoRoll = pianoRoll;
223
  this.svg = svg;