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
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>
精彩评论