commit/galaxy-central: jgoecks: Add utility function to circster that determines whether an element is visible.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/501641b6f680/ changeset: 501641b6f680 user: jgoecks date: 2012-09-20 21:39:57 summary: Add utility function to circster that determines whether an element is visible. affected #: 1 file diff -r b7fdcf887f2da2e4ba19b5894f56b3807e98bdf4 -r 501641b6f680b88f5e1ef78e1b8080853d59dea8 static/scripts/viz/circster.js --- a/static/scripts/viz/circster.js +++ b/static/scripts/viz/circster.js @@ -3,8 +3,32 @@ // General backbone style inheritence var Base = function() { this.initialize && this.initialize.apply(this, arguments); }; Base.extend = Backbone.Model.extend; +var SVGUtils = Backbone.Model.extend({ + + /** + * Returns true if element is visible. + */ + is_visible: function(svg_elt, svg) { + var eltBRect = svg_elt.getBoundingClientRect(), + svgBRect = $('svg')[0].getBoundingClientRect(); + + if (// To the left of screen? + eltBRect.right < 0 || + // To the right of screen? + eltBRect.left > svgBRect.right || + // Above screen? + eltBRect.bottom < 0 || + // Below screen? + eltBRect.top > svgBRect.bottom) { + return false; + } + return true; + } + +}); + /** - * Renders a full circster visualization + * Renders a full circster visualization. */ var CircsterView = Backbone.View.extend({ className: 'circster', @@ -23,7 +47,7 @@ height = self.$el.height(), // Compute radius start based on model, will be centered // and fit entirely inside element by default - init_radius_start = ( Math.min(width,height)/2 - + init_radius_start = ( Math.min(width, height)/2 - this.model.get('tracks').length * (this.dataset_arc_height + this.track_gap) ); // Set up SVG element. @@ -38,6 +62,13 @@ svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"); + var utils = new SVGUtils(); + var visible_elts = d3.selectAll('path').filter(function(d, i) { + return utils.is_visible(this, svg); + }); + visible_elts.each(function(d, i) { + console.log(this.attr('title')); + }); })) .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")") .append('svg:g'); @@ -57,7 +88,7 @@ total_gap: self.total_gap }); - track_renderer.render( svg ); + track_renderer.render(svg); }); } Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket