Skip to content

Commit

Permalink
check if offset>0 during instantiation, add warning, update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
MatSchaeff committed May 24, 2016
1 parent fda2987 commit 9bdb565
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dist/feature-viewer.bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/feature-viewer.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/feature-viewer.nextprot.js

Large diffs are not rendered by default.

16 changes: 12 additions & 4 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h4 class="text-center">Step 1 - Initialize the Feature Viewer</h4>
multiple of ten.
</li>
<li><strong>animation</strong> <em>(boolean)</em> : Animation during transition</li>
<li><strong>offset</strong> <em>(object)</em> : Specify an offset : offset:{start:40,end:100}</li>
<li><strong>offset</strong> <em>(object)</em> : Specify an offset (offset.start should always be > 0). <br>Ex : <span style="font-family:monospace;background-color:#eee;">offset:{start:40,end:100}</span></li>
</ul>
<p>The brush zoom will allow you to select a part of the sequence to zoom in. <br>
It may happen that the div is too small to display the sequence, but a zoom will make it
Expand Down Expand Up @@ -234,8 +234,12 @@ <h4 class="text-center">Step 2 - Add some features</h4>
<h4 class="text-center">Events</h4>
</div>
<div class="panel-body">
<p>You can listen for a click on a feature, and get the specific positions of this feature with the listener <strong>onFeatureSelected</strong>. <br>
This method take a custom function in parameter allowing you to link this event with the rest of your application.</p>
<p>You can listen for some events :</p>
<ul>
<li><strong>onFeatureSelected</strong> : A click on a feature, return an object with the specific positions of this feature</li>
<li><strong>onZoom</strong> : When a zoom occurs, return an object with the coordinates and zoom level</li>
</ul>
<p>Those methods take a custom function (callback) in parameter, receiving the event object, allowing you to link the event with the rest of your application.</p>
</div>
<form>
<textarea id="code3" name="code3" style="width:500px;max-height:200px;overflow:auto;font-size:11px;">
Expand Down Expand Up @@ -303,7 +307,11 @@ <h4 class="text-center">Events</h4>
ft3.onFeatureSelected(function (d) {
console.log(d.detail);
});


//Get and print in the browser console the zoom level and coordinates
ft3.onZoom(function (d) {
console.log(d.detail);
});

</textarea>
</form>
Expand Down
10 changes: 8 additions & 2 deletions src/feature-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ var FeatureViewer = (function () {
verticalLine: false
};
var offset = {start:1,end:fvLength};
if (options && options.offset) offset = options.offset;
if (options && options.offset) {
offset = options.offset;
if (offset.start < 1) {
offset.start = 1;
console.warn("WARNING ! offset.start should be > 0. Thus, it has been reset to 1.");
}
}
var pathLevel = 0;
var svg;
var svgContainer;
Expand Down Expand Up @@ -1416,7 +1422,7 @@ var FeatureViewer = (function () {

if (!$.fn.popover) {
options.bubbleHelp = false;
console.warn("The bubble help requires tooltip and popover bootrstrap js libraries. The feature viewer will continue to work, but without the info bubble");
console.warn("The bubble help requires tooltip and popover bootstrap js libraries. The feature viewer will continue to work, but without the info bubble");
}

// Create SVG
Expand Down

0 comments on commit 9bdb565

Please sign in to comment.