2

i'm having a problem with Galleria. the following code:

<script type="text/javascript">
    $(document).keypress(function(e)
      {
        switch(e.keyCode)
        {
          case 37: //press left arrow  
                $.galleria.prev();
                break;
          case 39: //press right arrow
                $.galleria.next();
                break;  
        }
      });


</script>

won't work, it says: $.galleria is undefined if i use instead Galleria.prev() and Galleria.next() then it says: Galleria.next is not a function, and the same fo prev.

i hope somebody with more experience can help me.

Thanks in advance, Adam

Edwardfmo
  • 77
  • 6

1 Answers1

4

galleria seems to have an attachKeyboard method, but i can't get that to work. but playing around with the code you have above, i managed to get arrow controls. try this:

<script>
//start galleria
Galleria.loadTheme('galleria.classic.js');
$('#galleria').galleria();

//obtain galleria instance - this might be the step you are missing
var gallery = Galleria.get(0);

//essentially what you had above
document.onkeyup = KeyCheck;       
function KeyCheck(e) {
    var KeyID = (window.event) ? event.keyCode : e.keyCode;
    switch(KeyID) {
        case 37: //press left arrow 
            gallery.prev();
            break;
        case 39: //press right arrow
            gallery.next();
            break;
    }
}
</script>
John Dong
  • 56
  • 1
  • +1 ... found this answer while trying to understand why people kept suggesting `$.galleria.next()` would work, and it didn't for me...this *did* work. Anyone know what the difference in context is? – HostileFork says dont trust SE Apr 03 '12 at 09:07