flexysnap 0.4.0 → 0.4.1
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.
- package/package.json +1 -1
- package/src/wireframeUtils.js +15 -6
package/package.json
CHANGED
package/src/wireframeUtils.js
CHANGED
|
@@ -145,6 +145,13 @@ async function extractElementGroupData(page, elementGroup, groupIndex, elementId
|
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
function isRectWithinViewport(rect) {
|
|
149
|
+
return rect.right >= 0 &&
|
|
150
|
+
rect.left < window.innerWidth &&
|
|
151
|
+
rect.bottom >= 0 &&
|
|
152
|
+
rect.top < window.innerHeight;
|
|
153
|
+
}
|
|
154
|
+
|
|
148
155
|
function isElementVisible(element) {
|
|
149
156
|
const style = window.getComputedStyle(element);
|
|
150
157
|
if (style.display === 'none' ||
|
|
@@ -155,12 +162,9 @@ async function extractElementGroupData(page, elementGroup, groupIndex, elementId
|
|
|
155
162
|
return false;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
const rect = element.getBoundingClientRect()
|
|
165
|
+
const rect = element.getBoundingClientRect();
|
|
159
166
|
|
|
160
|
-
return rect
|
|
161
|
-
rect.left < window.innerWidth &&
|
|
162
|
-
rect.bottom >= 0 &&
|
|
163
|
-
rect.top < window.innerHeight;
|
|
167
|
+
return isRectWithinViewport(rect);
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
function getElementsWithDirectText(root, textIgnoreClasses) {
|
|
@@ -237,9 +241,14 @@ async function extractElementGroupData(page, elementGroup, groupIndex, elementId
|
|
|
237
241
|
if (isNested)
|
|
238
242
|
continue;
|
|
239
243
|
|
|
244
|
+
const boundingRect = getTextNodeBoundingBox(descendant);
|
|
245
|
+
|
|
246
|
+
if (!isRectWithinViewport(boundingRect))
|
|
247
|
+
continue;
|
|
248
|
+
|
|
240
249
|
texts.push({
|
|
241
250
|
text: text,
|
|
242
|
-
boundingRect:
|
|
251
|
+
boundingRect: boundingRect
|
|
243
252
|
});
|
|
244
253
|
}
|
|
245
254
|
}
|