New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drag Area cannot be initialized by a script after page loads. #1355
Comments
The drag area is checked on the application startup. Dynamic check is not implemented, but it can be done with MutationObserver |
@r0x0r Would you be kind enough to provide an example of this implementation so I can understand it further? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The message to post on the issue when closing it. If none provided, will not comment when closing an issue. |
@JustAnEric look at // Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
for(var i = 0; i < mutationsList.length; i++) {
var mutation = mutationsList[i];
// Check if any of the added nodes have the class '.drag-region-selector'
if (mutation.type === 'childList') {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1 && node.classList.contains('%(drag_selector)s')) {
node.addEventListener('mousedown', onMouseDown);
}
});
} else if (mutation.type === 'attributes' && mutation.target.classList.contains('%(drag_selector)s')) {
node.addEventListener('mousedown', onMouseDown);
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the document for configured mutations
observer.observe(document, config);
// Later, you can disconnect the observer when you don't need it anymore
// observer.disconnect(); |
The message to post on the issue when closing it. If none provided, will not comment when closing an issue. |
How would PyWebView load that JavaScript in? I'm guessing |
Specification
Description
PyWebView is unable to initialize a drag area after the page loads. I am trying to make a custom Spotify client and I initialize the drag area like this:
How can I make PyWebView sort of check for the
pywebview-drag-region
class name again or is there an alternative?The text was updated successfully, but these errors were encountered: