[#9] ensure that callback is a function (defined) before setting up it

this was breaking it on OSX/Safari …
[#349] restore the viewport.setBounds function (but now with more parameters)