diff --git a/d3.layout.cloud.js b/d3.layout.cloud.js index f035837..b15b09e 100644 --- a/d3.layout.cloud.js +++ b/d3.layout.cloud.js @@ -15,6 +15,7 @@ timeInterval = Infinity, event = d3.dispatch("word", "end"), timer = null, + overflow = false, cloud = {}; cloud.start = function() { @@ -101,7 +102,11 @@ tag.y = startY + dy; if (tag.x + tag.x0 < 0 || tag.y + tag.y0 < 0 || - tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) continue; + tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) { + if (!overflow) { + continue; + } + } // TODO only check for collisions within current bounds. if (!bounds || !cloudCollide(tag, board, size[0])) { if (!bounds || collideRects(tag, bounds)) { @@ -189,6 +194,12 @@ return cloud; }; + cloud.overflow = function(x) { + if (!arguments.length) return overflow; + overflow = d3.functor(x); + return cloud; + }; + return d3.rebind(cloud, event, "on"); } diff --git a/examples/simple_with_overflow.html b/examples/simple_with_overflow.html new file mode 100644 index 0000000..eaeb03c --- /dev/null +++ b/examples/simple_with_overflow.html @@ -0,0 +1,44 @@ + + + + + +