foex-open-source / fos-splitter

MIT License
8 stars 1 forks source link

Javascript Expand/Collapse Split Region #6

Open pettinger opened 2 years ago

pettinger commented 2 years ago

Is there a way to expand/collaps the split region using js? I have a customer request to trigger expand/colapse by a button, not mousclick on designated the splitter area?

regards Peter

foex-open-source commented 2 years ago

it's not really supported, but something like this should work:

let splitter = $('#myRegionId .fos-Splitter').data().apexSplitter;
// collapse
splitter._setPos(splitter._getPos(), true);
// expand(/restore)
splitter._setPos(splitter._getPos(), false);
pettinger commented 2 years ago

Works great...except one little glitch: i placed the js snippet in an da of a button. after the page load setPos need to be called 2times to show up. Afterwards expand/clollapse work as suggested after every call. i did check getPos, after the first call it returns 1, even i setPos with a fixed value strange...