Methods

A Relapse instance also expose some basic methods for programmatic control.

import relapse from 'relapse';

const method = relapse('.selector');

method.expand(0);           // Expands fold at index 0
method.expand('foo');       // Expands fold with id value of "foo"
method.collapse(1);         // Collapse fold at index 1
method.collapse('bar');     // Collapse fold with id value of "bar"
method.destroy();           // Destroy the relapse instance
method.reinit();            // Destroy and reinitialize instance

Example

Click the buttons to open and close folds. This example is using the expand() and collapse() methods as we have demonstrated above. We have enabled multiple and set persist to false on this instance of Relapse so all folds can be expanded and collapsed.

Foo

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Elementum sagittis vitae et leo duis ut. Ut tortor pretium viverra suspendisse potenti.

Bar

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tincidunt nunc pulvinar sapien et ligula ullamcorper malesuada proin. Ac tortor dignissim convallis aenean et tortor at risus.

Baz

Commodo sed egestas egestas fringilla phasellus faucibus. Eu tincidunt tortor aliquam nulla facilisi cras fermentum. Nullam eget felis eget nunc lobortis mattis. Et netus et malesuada fames ac turpis egestas maecenas. Vitae turpis massa sed elementum tempus egestas.