===== Usage ===== This guide contains Javascript usage, see :ref:`Markup Guide` and :ref:`Themes` for Html and CSS usage. In html file there are two nested div elements with class name *.rs-container* and *.rs-srg3d* which serve as the base container. .. code-block:: html :linenos:
...
To bootstrap the app in javascript, query *.rs-srg3d* element and pass it as an input argument to PhotoWheel constructor: .. code-block:: javascript :linenos: var el = document.querySelector('.rs-srg3d'); var srg3d = new SpiralGallery(el); A second object argument filled with :ref:`configuration options` can be passed to the constructor: .. code-block:: javascript :linenos: var srg3d = new SpiralGallery(el, { containerZ:-2500, orientation:'vertical', boxThickness:20, backImage:'assets/back.png', categoryMenu:{ horizontal:true } }); API Methods ----------- * **target(index)** Target an item, bring it to center front and show its title and description. *index*: The item index * **next** Target the next item in current category * **prev** Target the previous item in current category Dispatched Events ----------------- * **cload** Fire when a category is beginning to load * **cloadcomplete** Fire when a category is finished loading * **target** Fire when an item is being targeted Examples -------- Assign srg3d to window context then call its API methods: .. code-block:: javascript :linenos: window.srg3d = srg3d; // Target item with id: 1 srg3d.target(1); // ... // Target next item srg3d.next(); // ... // Target previous item srg3d.prev(); Add event listeners: .. code-block:: javascript :linenos: // Trigger every time an item is targeted srg3d.addEventListener('target', function(e) { console.log(e.detail); }); // Trigger when a category begins to load srg3d.addEventListener('cload', function(e) { console.log(e.detail); }); // Trigger when a category finished loading srg3d.addEventListener('cloadcomplete', function(e) { console.log(e.detail); });