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

Allow moving a webcontents to a different webview #7157

Merged
merged 1 commit into from Sep 20, 2016

Conversation

Projects
None yet
5 participants
@Mossop
Contributor

Mossop commented Sep 9, 2016

This adds a guestinstance attribute to webviews. When the webview first loads it updates its guestinstance with the instance ID for the webcontents. Setting the attribute to an existing guestinstance moves the webcontents to the new webview and sends a destroy event on the original webview. This fixes #1871.

This also adds the did-attach event since it is useful for detecting when the move is complete and I think that that fixes #6972 as did-attach is sent for the first navigation too.

Add a guestinstance attribute to webviews reflecting their current guest
instance ID and allowing moving a guest instance to a new webview.
@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Sep 20, 2016

This is awesome. 👍

@zcbenz zcbenz merged commit e3e4506 into electron:master Sep 20, 2016

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@TimNZ

This comment has been minimized.

TimNZ commented Sep 23, 2016

@Mossop I can't figure out whether this is of interest to me - what real world coolness does this enable? Dragging content between BrowserWindow?

Update:

Ok I have now read #1871 but would like to see a code or pseudo-code example of a recommended approach.

@Mossop

This comment has been minimized.

Contributor

Mossop commented Sep 23, 2016

@TimNZ The tests show some examples but basically if you take the value of the guestinstance attribute from an active webview and set it on a different webview, even in a different BrowserWindow, then the content will move to the new webview and the old will receive a destroy event.

@TimNZ

This comment has been minimized.

TimNZ commented Sep 23, 2016

Thanks, was just reading through the tests now. I guess there is still limitations around implementing a similar tab drag into new window like a browser as we don't have the native GUI mechanism in Electron to do it?

@Mossop

This comment has been minimized.

Contributor

Mossop commented Sep 23, 2016

@TimNZ It's doable with html5 drag and drop APIs but you would of course have to write the app code yourself.

@TimNZ

This comment has been minimized.

TimNZ commented Sep 23, 2016

@Mossop Cool thanks. I'm building a business app MVP and not strong on HTML5, will have an expert doing that stuff. Great work!

@davej

This comment has been minimized.

Contributor

davej commented Sep 24, 2016

Could it be possible to duplicate/clone the webcontents? i.e., not 'destroy' the existing window?

This could allow multi-window apps that don't incur the penalty of the large init time associated with initialising javascript frameworks etc..

I created an issue for this a few months ago at #6063. Is something like this definitely not feasible? It could be a game-changer for multi-window electron apps if something like this was possible.

@Mossop

This comment has been minimized.

Contributor

Mossop commented Sep 24, 2016

@davej I can't say for certain that it's impossible but at the very least I think it would be extremely difficult to achieve that.

@subwaymatch

This comment has been minimized.

subwaymatch commented Mar 8, 2017

Didn't know this feature was added. This is ex-tremely awesome! Thanks @Mossop!

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