happo 2.0.7 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/happo/public/happo-runner.js +45 -6
- data/lib/happo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ab62af6f8c5cba90963fcca9ffa73576b2f161f
|
4
|
+
data.tar.gz: c12b3dcee9e5f6c0935333494214b693faa09258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 743c15567f974688f373a3e1d114509013c1f357b803b00273cfb39691462e6d5a5b072ceb2f87c138fcec4a0b408efe0e4eba674587c69e4874aa066e2f07aa
|
7
|
+
data.tar.gz: 56d4de2b0e53e73ed4cd85823d6641be136537b354feb9edf500be578289d9a718e0d493f4c5f4fe76fc7d64c3a4ff4ebaae0811e25b43e7a36ebb40f4c3787f
|
@@ -153,6 +153,50 @@ window.happo = {
|
|
153
153
|
}
|
154
154
|
},
|
155
155
|
|
156
|
+
// This function takes a node and a box object that we will mutate.
|
157
|
+
getFullRectRecursive: function(node, box) {
|
158
|
+
var rect = node.getBoundingClientRect();
|
159
|
+
|
160
|
+
box.bottom = Math.max(box.bottom, rect.bottom);
|
161
|
+
box.left = Math.min(box.left, rect.left);
|
162
|
+
box.right = Math.max(box.right, rect.right);
|
163
|
+
box.top = Math.min(box.top, rect.top);
|
164
|
+
|
165
|
+
for (var i = 0; i < node.children.length; i++) {
|
166
|
+
getFullRectRecursive(node.children[i], box);
|
167
|
+
}
|
168
|
+
},
|
169
|
+
|
170
|
+
// This function gets the full size of the given node, including all
|
171
|
+
// descendent nodes. This allows us to ensure that the screenshot includes
|
172
|
+
// absolutely positioned elements. It is important that this is fast, since we
|
173
|
+
// may be iterating over a high number of nodes.
|
174
|
+
getFullRect: function(node) {
|
175
|
+
var rect = node.getBoundingClientRect();
|
176
|
+
|
177
|
+
// Set up the initial object that we will mutate in our recursive function.
|
178
|
+
var box = {
|
179
|
+
bottom: rect.bottom,
|
180
|
+
left: rect.left,
|
181
|
+
right: rect.right,
|
182
|
+
top: rect.top,
|
183
|
+
};
|
184
|
+
|
185
|
+
// If there are any children, we want to iterate over them recursively,
|
186
|
+
// mutating our box object along the way to expand to include all descendent
|
187
|
+
// nodes.
|
188
|
+
for (var i = 0; i < node.children.length; i++) {
|
189
|
+
getFullRectRecursive(node.children[i], box);
|
190
|
+
}
|
191
|
+
|
192
|
+
// Do width and height calculations at the end, to avoid having to do them
|
193
|
+
// for every node.
|
194
|
+
box.width = box.right - box.left;
|
195
|
+
box.height = box.bottom - box.top;
|
196
|
+
|
197
|
+
return box;
|
198
|
+
},
|
199
|
+
|
156
200
|
processElem: function(currentExample, elem) {
|
157
201
|
try {
|
158
202
|
this.currentRenderedElement = elem;
|
@@ -166,14 +210,9 @@ window.happo = {
|
|
166
210
|
left: 0,
|
167
211
|
};
|
168
212
|
} else {
|
169
|
-
// We use elem.getBoundingClientRect() instead of offsetTop and its ilk
|
170
|
-
// because elem.getBoundingClientRect() is more accurate and it also
|
171
|
-
// takes CSS transformations and other things of that nature into
|
172
|
-
// account whereas offsetTop and company do not.
|
173
|
-
//
|
174
213
|
// Note that this method returns floats, so we need to round those off
|
175
214
|
// to integers before returning.
|
176
|
-
rect =
|
215
|
+
rect = this.getFullRect(elem);
|
177
216
|
}
|
178
217
|
|
179
218
|
return {
|
data/lib/happo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henric Trotzig
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-08-
|
12
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chunky_png
|