aboutsummaryrefslogtreecommitdiff
path: root/docs/hacking.rst
blob: 14d381036d9595568308a96087601f3776114d64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Hacking
=======
A plugin are expected to implement a function :code:`register(lightbox)` which will be called when passed the plugin to `LightBox.Core::registerPlugin`. See the full API at :doc:`api`.

A basic plugin could look like this.

.. code-block:: js
    :caption: LightBox.Contrib.MyExitPlugin.js

    class MyExitPlugin {

        register(lightbox) {
            lightbox.addOnEndListener(this.exited.bind(this));
        }

        exited() {
            console.log('lightbox exited');
        }

    }