|
From: Jochen J. <joc...@fi...> - 2025-06-02 14:50:11
|
Hi Robert!
Thank you for the hint about JSMol.full.js, that helped me to a solution. It is dirty, but works.
A few lines below the changes that you suggested, is the function _createCanvas2d. There are the lines defining w & h relative to the container, which return 0 (code lines ~13740). I have changed
var w = Math.round(container.width());
var h = Math.round(container.height());
To
var w = Math.max(100,Math.round(container.width()));
var h = Math.max(100,Math.round(container.height()));
And now everything runs smoothly.
For some reason the container width and height in this context are calculated as 0.
In instances created later on, width and height of the container have meaningful values, as I could verify while debugging.
JJ
On 2 Jun 2025, at 10:40, Robert Hanson <ha...@st...> wrote:
OK, using &j2sdebugcode did work, at least for the 16 version. (probably not yet implemented for v 14). The problem is in Platform.js. It is being passed (0,0) for (width,height) of the display. This is coming from check13c > onerror > _cover > _newCanvas > _createCanvas2d > where jmolc_appletdiv is reporting width and height undefined. That is because this onerror call is coming from jsmol.min.js
this._deferApplet ||
(
a._document ? (a._documentWrite(d), this._newCanvas(!1), d = '') : (
this._deferApplet = !0,
d += '<img width=0 height=0 src=. onerror=' + b + '._cover(false) >'
)
);
whereas in v 14 the code is:
(
b._document ? (b._documentWrite(m), this._getCanvas(!1), m = '') : (
this._deferApplet = !0,
m += '<script type="text/javascript">' + f + '._cover(false)</script>'
)
);
I can't remember why I changed that. But I am sure there was a reason. I think the error is thrown correctly. It was an attempt to run only after a clock tick caused by the image loading. Something that also could be done using a set timeout.
Your next test:
1) replace jsmol/jsmol.min.js with the jsmol/js/jsmol.full.js. This is the uncompressed version. So we can test.
2) on line 13698:
t += '<img width=0 height=0 src=. onerror=' + id + '._cover(false) >';
change that to
t += '<script>setTimeout(function() { ' + id + '._cover(false)},500)</script> ';
Let's see if that does the trick. Leaving a 1/2-second delay for the removal of the spinning widget cover.
(You could also just change in jsmol.min.js
d += '<img width=0 height=0 src=. onerror=' + b + '._cover(false) >'
to
d += '<script>setTimeout(function() { ' + b + '._cover(false)},500)</script> ';
and not futz with jsmol.full.js.
|