Skip to content

Commit 41e47b2

Browse files
committed
Merge in ResizeObserver polyfill
2 parents fd77430 + 0b1269e commit 41e47b2

File tree

7 files changed

+1005
-11
lines changed

7 files changed

+1005
-11
lines changed

InterSpec_resources/D3TimeChart.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ D3TimeChart = function (elem, options) {
215215
if (typeof this.options.chartLineWidth !== "number")
216216
this.options.chartLineWidth = 1;
217217

218-
// minimum selection width option. Default value taken from D3SpectrumChart
218+
// minimum selection width option. Currently only applies to "zoom" selection. Default value copied from D3SpectrumChart
219219
if (typeof this.options.minSelectionWidth !== "number")
220220
this.options.minSelectionWidth = 8;
221221

@@ -293,7 +293,7 @@ D3TimeChart = function (elem, options) {
293293
sampleNumberToIndexMap: null,
294294
unzoomedCompressionIndex: 0,
295295
},
296-
selection: null, // maybe would have been better to have named this "zoom": stores data related to zoom selection (e.g. data domain of magnified area, corresponding compression index to use for plotting this magnified data). NOTE: set to null when zoomed all the way out.
296+
selection: null, // maybe would have been better to have named this "zoom": stores data related to zoom selection (e.g. x data domain of magnified area, corresponding compression index to use for plotting this magnified data). IMPORTANT NOTE: set to null when zoomed all the way out.
297297
regions: null,
298298
brush: new BrushX(),
299299
height: null,
@@ -362,6 +362,7 @@ D3TimeChart = function (elem, options) {
362362
evt.key >= "A" &&
363363
evt.key <= "Z"
364364
) {
365+
// convert uppercase char to lowercase
365366
var unmodifiedEventKey = String.fromCharCode(evt.key.charCodeAt() + 32);
366367
self.keysHeld[unmodifiedEventKey] = true;
367368
} else {
@@ -388,6 +389,7 @@ D3TimeChart = function (elem, options) {
388389
evt.key >= "A" &&
389390
evt.key <= "Z"
390391
) {
392+
// convert uppercase char to lowercase
391393
var unmodifiedEventKey = String.fromCharCode(evt.key.charCodeAt() + 32);
392394
delete self.keysHeld[unmodifiedEventKey];
393395
} else {
@@ -625,10 +627,10 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
625627
brush.setScale(scales.xScale);
626628
}
627629
// DEFINE HANDLERS AND LISTENERS
628-
// TODO: To add additional touch functionality, add analogous touch gestures (to right click, alt key, ctrl key-- to perform zoom and background selection)
629630

630631
/**
631-
* Handler for the initiation of a selection gesture.
632+
* Callback for handling the initiation of a selection gesture (for both mouse and touch).
633+
* @param {*} options : an object that defines certain options. For example, pass { touch: true } to execute touch codepath
632634
*/
633635
var startSelection = (options) => {
634636
if (options && options.touch) {
@@ -704,7 +706,8 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
704706
};
705707

706708
/**
707-
* Handler for the progression of a selection gesture.
709+
* Callback for handling the progression of a selection gesture (for both mouse and touch).
710+
* @param {*} options : an object that defines certain options. For example, pass { touch: true } to execute touch codepath
708711
*/
709712
var moveSelection = (options) => {
710713
if (options && options.touch) {
@@ -745,7 +748,8 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
745748
};
746749

747750
/**
748-
* Handler for the termination of a selection gesture.
751+
* Callback for handling the termination of a selection gesture (for both mouse and touch).
752+
* @param {*} options : an object that defines certain options. For example, pass { touch: true } to execute touch codepath
749753
*/
750754
var endSelection = (options) => {
751755
if (options && options.touch) {
@@ -778,7 +782,7 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
778782
// handle foreground or background selection
779783

780784
// only enable highlighting if brush forward, for more alignment with expected behavior
781-
if (lIdx < rIdx) {
785+
if (brush.getStart() <= brush.getEnd()) {
782786
// Defined from docs on Wt::KeyboardModifier
783787
var keyModifierMap = {
784788
altKey: 0x4,
@@ -847,6 +851,10 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
847851
var newSelection = null;
848852
var newScale = brush.getScale();
849853

854+
/**
855+
* Callback for handling the initiation of a panning gesture (for both mouse and touch).
856+
* @param {*} options : an object that defines certain options. For example, pass { touch: true } to execute touch codepath
857+
*/
850858
var startPanDragSelection = (options) => {
851859
if (options && options.touch) {
852860
d3.event.preventDefault();
@@ -864,6 +872,10 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
864872
d3.select("body").style("cursor", "ew-resize");
865873
};
866874

875+
/**
876+
* Callback for handling the progression of a panning gesture (for both mouse and touch).
877+
* @param {*} options : an object that defines certain options. For example, pass { touch: true } to execute touch codepath
878+
*/
867879
var movePanDragSelection = (options) => {
868880
if (options && options.touch) {
869881
d3.event.preventDefault();
@@ -886,6 +898,10 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
886898
}
887899
};
888900

901+
/**
902+
* Callback for handling the termination of a panning gesture (for both mouse and touch).
903+
* @param {*} options : an object that defines certain options. For example, pass { touch: true } to execute touch codepath
904+
*/
889905
var endPanDragSelection = (options) => {
890906
if (options && options.touch) {
891907
d3.event.preventDefault();
@@ -915,7 +931,7 @@ D3TimeChart.prototype.reinitializeChart = function (options) {
915931

916932
this.bottomAxisRect.call(panDrag);
917933

918-
// Special behavior for PAN interaction mode.
934+
// Special behavior for PAN interaction mode, which allows panning by dragging on the main interaction area of the chart
919935
if (this.userInteractionMode === this.UserInteractionModeEnum.PAN) {
920936
this.rect
921937
.on("touchstart", () => startPanDragSelection({ touch: true }))
@@ -1481,6 +1497,7 @@ D3TimeChart.prototype.updateChart = function (
14811497
this.horizontalLeftGridG.selectAll("g.tick");
14821498
horizontalLeftGridLines.each(function (d, i) {
14831499
var tickLine = d3.select(this).select("line");
1500+
// special handling for grid lines would be added here. (e.g. classifying grid lines as minor or major)
14841501
});
14851502
} else {
14861503
this.horizontalLeftGridG.selectAll("*").remove();
@@ -1560,6 +1577,7 @@ D3TimeChart.prototype.updateChart = function (
15601577
this.horizontalRightGridG.selectAll("g.tick");
15611578
horizontalRightGridLines.each(function (d, i) {
15621579
var tickLine = d3.select(this).select("line");
1580+
// special handling for grid lines would be added here. (e.g. classifying grid lines as minor or major)
15631581
});
15641582
} else {
15651583
this.horizontalRightGridG.selectAll("*").remove();
@@ -2310,8 +2328,8 @@ D3TimeChart.prototype.handleMouseWheel = function (deltaX, deltaY, mouseX) {
23102328
var zoomStepSize =
23112329
0.001 * Math.exp(2, this.state.data.unzoomedCompressionIndex);
23122330

2313-
let newLeftExtent;
2314-
let newRightExtent;
2331+
var newLeftExtent = null;
2332+
var newRightExtent = null;
23152333

23162334
if (Math.abs(deltaY) >= Math.abs(deltaX)) {
23172335
// if scroll vertical, zoom
@@ -2327,7 +2345,7 @@ D3TimeChart.prototype.handleMouseWheel = function (deltaX, deltaY, mouseX) {
23272345
);
23282346
} else {
23292347
// if scroll horizontal, pan
2330-
let panStepSize =
2348+
var panStepSize =
23312349
deltaX *
23322350
0.1 *
23332351
this.state.data.formatted[this.state.data.unzoomedCompressionIndex]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Denis Rul
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)