Skip to content

Commit 4d8d7d3

Browse files
author
Syed Usama Nasir
committed
Fixed scroll type heat map elements clustering at one point of the page
1 parent 607b0e8 commit 4d8d7d3

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $ rake db:migrate
5353

5454
5. Include where to show the heatmap:
5555
```erb
56-
<%= show_heatmap(request.path) %>
56+
<%= show_heatmap %>
5757
```
5858
6. Before adding headmap.js in the application install **jquery-rails** gem and require it in application.js file
5959
```js
@@ -68,14 +68,14 @@ $ rake db:migrate
6868
## Viewing Heat Maps
6969
Use the helper
7070
```erb
71-
<%= show_heatmap(request.path) %>
71+
<%= show_heatmap %>
7272
```
7373
The argument is the path of current page. This way the helper will only display the respective heatmap.
7474
The viewing can be done in multiple ways, for example if you want only the admin users to view heatmap, you can do something like:
7575

7676
```erb
7777
<% if admin_user_signed_in? %>
78-
<%= show_heatmap(request.path) %>
78+
<%= show_heatmap %>
7979
<% end %>
8080
```
8181

@@ -89,7 +89,7 @@ You can use:
8989

9090
```erb
9191
<% if request.query_parameters.include?("see_heatmap") %>
92-
<%= show_heatmap(request.path) %>
92+
<%= show_heatmap %>
9393
<% end %>
9494
```
9595

lib/heatmap/rails/helper.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,8 @@ def show_heatmap(type = false)
240240
heatmapInstance.addData(data_xpath);
241241
var scroll = JSON.parse('#{raw(@scroll_data.to_json.html_safe)}');
242242
var scroll_data = scroll.map(function(element){
243-
var element = getElement(element.xpath);
244-
if (!element)
245-
return;
246-
width = element.getBoundingClientRect().width;
247-
height = element.getBoundingClientRect().height;
243+
width = getElement(element.xpath).getBoundingClientRect().width;
244+
height = getElement(element.xpath).getBoundingClientRect().height;
248245
dot = document.createElement('div');
249246
dot.className = "dot";
250247
dot.style.left = (getOffset(element.xpath).x+ (width * element.offset_x)) + "px";

lib/heatmap/rails/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Heatmap
22
module Rails
3-
VERSION = "0.1.4"
3+
VERSION = "0.2.0"
44
end
55
end

0 commit comments

Comments
 (0)