Skip to content

Commit f463d55

Browse files
committed
google analytics hooked up + scroll to css when copied
1 parent 305b5a4 commit f463d55

8 files changed

+93
-12
lines changed

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@
1818
"always"
1919
],
2020
"no-console": "warn"
21+
},
22+
"globals": {
23+
"ga": true
2124
}
2225
}

assets/js/app/texture-packer.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const GITHUB_URL = '/*\nResponsive CSS Sprite created using: ' +
33
'https://responsive-css.us/\n' +
44
'*/\n\n';
55

6+
const DEBUG = false;
7+
68
function findNode(root, w, h) {
79
if (root.used) {
810
return findNode(root.right, w, h) || findNode(root.down, w, h);
@@ -126,9 +128,10 @@ export default class TexturePacker {
126128
let texture = this.textures[i];
127129
if(texture.fit) {
128130

129-
// turn on for testing
130-
// ctx.fillRect(texture.fit.x + pad, texture.fit.y + pad, texture.w, texture.h);
131-
// ctx.stroke();
131+
if(DEBUG) {
132+
ctx.fillRect(texture.fit.x + pad, texture.fit.y + pad, texture.w, texture.h);
133+
ctx.stroke();
134+
}
132135

133136
ctx.drawImage(texture.img, texture.fit.x + pad, texture.fit.y + pad);
134137

assets/js/app/view.js

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import {qs, $on, debounce} from './helpers';
22
let instance = null;
33

4+
function scrollIntoView(eleID) {
5+
var e = qs(eleID).getBoundingClientRect();
6+
var h = qs('#header').getBoundingClientRect();
7+
window.scrollTo(0, e.top - h.height - 100);
8+
}
9+
410
export default class View {
511

612
constructor(template) {
@@ -20,11 +26,21 @@ export default class View {
2026
this.$path = qs('#path');
2127
this.$canvas = qs('#canvas');
2228
this.$css = qs('#css');
29+
this.$copy = qs('#copy');
2330
this.$download = qs('#download');
2431
this.dimensions = qs('#dimensions');
2532
this.$dropbox = qs('#dropbox');
2633
this.$fileList.appendChild(this.$listItems);
2734

35+
$on(this.$copy, 'click', ()=>{
36+
scrollIntoView('#css');
37+
ga('send', {
38+
hitType: 'event',
39+
eventCategory: 'Copy CSS',
40+
eventAction: 'click'
41+
});
42+
});
43+
2844
}
2945

3046
bindFileExplorer (handler) {
@@ -34,7 +50,11 @@ export default class View {
3450
this.$fileInput.click();
3551
}
3652
e.preventDefault();
37-
// TODO: Analytics
53+
ga('send', {
54+
hitType: 'event',
55+
eventCategory: 'File Explorer',
56+
eventAction: 'click'
57+
});
3858
});
3959

4060
$on(this.$fileInput, 'change', function(){
@@ -64,6 +84,12 @@ export default class View {
6484

6585
handler(files);
6686

87+
ga('send', {
88+
hitType: 'event',
89+
eventCategory: 'File Drop',
90+
eventAction: 'drop'
91+
});
92+
6793
});
6894

6995
}
@@ -80,10 +106,20 @@ export default class View {
80106

81107
bindRemoveBtn (handler) {
82108
$on(this.$fileList, 'click', handler);
109+
ga('send', {
110+
hitType: 'event',
111+
eventCategory: 'Remove Image',
112+
eventAction: 'click'
113+
});
83114
}
84115

85116
bindDownloadBtn(handler) {
86117
$on(this.$download, 'click', handler);
118+
ga('send', {
119+
hitType: 'event',
120+
eventCategory: 'Sprite Download',
121+
eventAction: 'click'
122+
});
87123
}
88124

89125
setSettingsValues (settings) {

assets/js/bundle-167107567a.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/bundle-c882da457c.min.js

-1
This file was deleted.

assets/js/bundle.js

+43-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)