Listen to ElementSizeChanged event
This commit is contained in:
parent
e4bb456964
commit
b5c9fe78f1
9 changed files with 104 additions and 8 deletions
|
@ -86,6 +86,9 @@ class WebViewImpl
|
|||
@browserPluginNode.removeAttribute webViewConstants.ATTRIBUTE_INTERNALINSTANCEID
|
||||
@internalInstanceId = parseInt newValue
|
||||
|
||||
# Track when the element resizes using the element resize callback.
|
||||
webFrame.registerElementResizeCallback @internalInstanceId, @onElementResize.bind(this)
|
||||
|
||||
return unless @guestInstanceId
|
||||
|
||||
guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, @buildParams()
|
||||
|
@ -120,6 +123,18 @@ class WebViewImpl
|
|||
# changed.
|
||||
@dispatchEvent webViewEvent
|
||||
|
||||
onElementResize: (oldSize, newSize) ->
|
||||
# Dispatch the 'resize' event.
|
||||
resizeEvent = new Event('resize', bubbles: true)
|
||||
resizeEvent.oldWidth = oldSize.width
|
||||
resizeEvent.oldHeight = oldSize.height
|
||||
resizeEvent.newWidth = newSize.width
|
||||
resizeEvent.newHeight = newSize.height
|
||||
@dispatchEvent resizeEvent
|
||||
|
||||
if @guestInstanceId
|
||||
guestViewInternal.setSize @guestInstanceId, normal: newSize
|
||||
|
||||
createGuest: ->
|
||||
guestViewInternal.createGuest @buildParams(), (guestInstanceId) =>
|
||||
@attachWindow guestInstanceId
|
||||
|
@ -167,9 +182,10 @@ class WebViewImpl
|
|||
# the on display:block.
|
||||
css = window.getComputedStyle @webviewNode, null
|
||||
elementRect = @webviewNode.getBoundingClientRect()
|
||||
params.elementSize =
|
||||
width: parseInt(elementRect.width) || parseInt(css.getPropertyValue('width'))
|
||||
height: parseInt(elementRect.height) || parseInt(css.getPropertyValue('height'))
|
||||
params.elementWidth = parseInt(elementRect.width) ||
|
||||
parseInt(css.getPropertyValue('width'))
|
||||
params.elementHeight = parseInt(elementRect.height) ||
|
||||
parseInt(css.getPropertyValue('height'))
|
||||
params
|
||||
|
||||
attachWindow: (guestInstanceId) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue