Small patch for qml scene resizes
Pavel Vasev
pavel.vasev at gmail.com
Wed Mar 11 05:13:36 UTC 2015
Hi Anton!
Please consider small replacement for you code block in `function
QMLItem(meta)`
which rules qml scene global width/height.
// e.g. your commit:
https://github.com/akreuzkamp/qmlweb/commit/4c9e432e818197289154e58c31e511188835b2cf
There are 2 changes.
1. window.onresize function is changed to addEventListener("resize") call.
2. In case when qml scene is placed in some dom tag (case 2),
we have to call `self.implicitHeight =` and `self.implicitWidth =`
each time the rootElement changes it's geometry
to reposition child elements of qml scene
Also there is a small note. Because in qmlweb implicitHeight= is chained
to updateHGeometry,
which in turn calls height=, which in turn sets element dom style, we have
to set
rootElement's outer width/height styles to !important. Maybe it should be
noted somewhere in the docs. This note is not regarding to the current
patch.
-----------------------------------------------------------------------------------------
// Init size of root element
if (engine.renderMode == QMLRenderMode.DOM
&& this.$parent === null) {
if (engine.rootElement == undefined) {
// Case 1: Qml scene is placed in body tag
// event handling by addEventListener is probably better than
setting window.onresize
var updateQmlGeometry = function() {
self.implicitHeight = window.innerHeight;
self.implicitWidth = window.innerWidth;
}
window.addEventListener( "resize", updateQmlGeometry );
updateQmlGeometry();
} else {
// Case 2: Qml scene is placed in some element tag
// we have to call `self.implicitHeight =` and
`self.implicitWidth =`
// each time the rootElement changes it's geometry
// to reposition child elements of qml scene
// it is good to have this as named method of dom element, so
we can call it
// from outside too, whenever element changes it's geometry
(not only on window resize)
this.dom.updateQmlGeometry = function() {
self.implicitHeight = self.dom.offsetHeight;
self.implicitWidth = self.dom.offsetWidth;
};
window.addEventListener( "resize", this.dom.updateQmlGeometry );
this.dom.updateQmlGeometry();
}
}
-----------------------------------------------------------------------------------------
p.s. BTW have you seen my pull request at github?
https://github.com/akreuzkamp/qmlweb/pull/1
Best Regards,
Pavel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/qmlweb/attachments/20150311/891f499d/attachment.html>
More information about the QmlWeb
mailing list