===== 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-pr3d* which serve as the base container. .. code-block:: html :linenos:
...
To bootstrap the app in javascript, query *.rs-pr3d* element and pass it as an input argument to PhotoRow constructor: .. code-block:: javascript :linenos: var el = document.querySelector('.rs-pr3d'); var pr3d = new PhotoRow(el); A second object argument filled with :ref:`configuration options` can be passed to the constructor: .. code-block:: javascript :linenos: var pr3d = new PhotoRow(el, { useMouseDrag:true, components:[0, 1, 2], itemDistance:400, shearAngle:45, roundCorner:10, viewAngleX:20, easing:'easeOutQuint', duration:1000, 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 pr3d to window context then call its API methods: .. code-block:: javascript :linenos: window.pr3d = pr3d; // Target item with id: 1 pr3d.target(1); // ... // Target next item pr3d.next(); // ... // Target previous item pr3d.prev(); Add event listeners: .. code-block:: javascript :linenos: // Trigger every time an item is targeted pr3d.addEventListener('target', function(e) { console.log(e.detail); }); // Trigger when a category begins to load pr3d.addEventListener('cload', function(e) { console.log(e.detail); }); // Trigger when a category finished loading pr3d.addEventListener('cloadcomplete', function(e) { console.log(e.detail); });