Skip to content

Conversation

@tgriesser
Copy link

Hey @dmtrKovalenko!

Was playing around with this library a bit and wanted to capture the locations of the highlighted diffs beyond just the diffLines

So I tried to implement a captureCoords option which outputs a diffCoords formatted as:

Array<[yAxis: number, ...xAxisRanges: Array<[number, number]>]>

so:

[
  [1169, [886, 888], [890, 892]],
  [1170, [885, 894], [896, 896]],
  [1171, [882, 899]],
  [1172, [878, 901]],
  [1173, [878, 902], [904, 904]],
  // ...
]

See the test/coords-fixture.json for an example.

Haven't written much ocaml, so possible it could be done simpler, but let me know what you think.

@dmtrKovalenko
Copy link
Owner

Hey @tgriesser long time no see. Thanks for the proposal I'll take my time to review it but I just wonder on the motivation. What are you exactly trying to perform? Why diff output / diff mask is not enough? How would you use the information for each individual pixel?

@tgriesser
Copy link
Author

Don't need every individual pixel, just the x-axis ranges of pixels for the given lines where there are diffs.

The idea is that if you have that info, you'd be able to draw a rough bounding boxes for the DOM around the various major elements that were affected when there's a diff and be able to use that information to find the actual elements where side-effects took place via elementFromPoint or something

Mostly just experimenting at this point, but figured it could also be useful if you wanted to do something like crop the image to the areas where there are changes or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants