Skip to content

Commit

Permalink
Merge pull request #4 from jafuentest/master
Browse files Browse the repository at this point in the history
Remove missing elements from scroll info
  • Loading branch information
hassanakram authored Jun 13, 2018
2 parents d50d179 + 511b171 commit e6bb55b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/heatmap/rails/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ def show_heatmap(path,type = false)
heatmapInstance.addData(data_xpath);
var scroll = JSON.parse('#{raw(@scroll_data.to_json.html_safe)}');
var scroll_data = scroll.map(function(element){
width = getElement(element.xpath).getBoundingClientRect().width;
height = getElement(element.xpath).getBoundingClientRect().height;
var element = getElement(element.xpath);
if (!element)
return;
width = element.getBoundingClientRect().width;
height = element.getBoundingClientRect().height;
dot = document.createElement('div');
dot.className = "dot";
dot.style.left = (getOffset(element.xpath).x+ (width * element.offset_x)) + "px";
Expand All @@ -261,6 +264,7 @@ def show_heatmap(path,type = false)
document.body.appendChild(dot);
});
scroll_data = scroll_data.filter(function(val){ return val!==undefined; });
</script>
JS

Expand Down

0 comments on commit e6bb55b

Please sign in to comment.