tungs / timesnap

Node.js program that takes screenshots at smooth intervals of web pages with JavaScript animations
BSD 3-Clause "New" or "Revised" License
234 stars 57 forks source link

Stop capture #56

Closed RhinoW closed 3 years ago

RhinoW commented 3 years ago

Checklist

Description

In my use case (and Issue #32) I don't know exactly how long the capture should be before hand. This PR allows page to use window.stopCapture() to control when capture ends.

tungs commented 3 years ago

Thanks for filing this. I like the idea of being able to stop capturing from the captured web page. There seem to be some minor issues (like typos), but my biggest concern is polluting the global namespace, so I'd prefer to use something more specific and less likely to conflict than window.stopCapture. I'll think about it this week.

RhinoW commented 3 years ago

This may be a better way to handle - https://github.com/tungs/timesnap/issues/24 - a captureWhileSelectorExists option.

RhinoW commented 3 years ago

Decision between

tungs commented 3 years ago

After mulling over the idea of polluting the global namespace with arbitrary names, I think a somewhat cleaner implementation is to allow the user to specify the name from the command line or config. Compared to the alternatives, this still allows for the stop functionality to be called from a command line invocation, while polluting with a user-chosen name.