1
3rd Party Plugins - (fb2k) / Re: JSplitter (splitter + SMP x64 alternative)
Last post by regor -You can check if a panel is visible with:
https://theqwertiest.github.io/foo_spider_monkey_panel/assets/generated_files/docs/html/window.html#.IsVisible
How to implement that on an actual script, obviously varies a lot. There is no callback to check when the panel visibility changes, so you either use an interval on the background or some clever trick.
As an example, for my timeline script which displays charts... I could add a check for window.IsVisible, so whenever it's false, there is no processing. Then at on_paint callback, I could check if there is data already calculated, otherwise calculate it. That would account to what happens when the panel was initially hidden and I open it at a later point, there would be no data but I force it at that point. Obviously that implies a performance penalty when switching visibility, but you gain performance when it's hidden. (library tree for ex is always being processed on the background even if not used)
Code: [Select]
const myData = [];
function calcData() {
myData.length = 0;
myData.push('this is data')
.... // data code
}
function on_item_focus_change() {
if (window.IsVisible) {
calcData();
} else {
myData.length = 0;
}
}
function on_paint() {
if (!myData.length) {calcData()}
.... // Paint code
}