Zoom in and out feature
Hello,
Is there a way to create a zoom in and out feature with using mouse scrolling?
Thanks
Hello,
Is there a way to create a zoom in and out feature with using mouse scrolling?
Thanks
For ActionScript you could read articles like this one:
Flash Mouse Wheel Support | Hook - Labs
For HTML5 Canvas, here's what @klad suggested in another post:
document.getElementById('canvas').addEventListener('mousewheel',f.bind(this));
document.getElementById('canvas').addEventListener('DOMMouseScroll',f.bind(this));
function f(e){
//e.detail
}
Exactly like that it's not the whole answer, there is wheelDeltaY, so this will give you a useful number about how quickly the user was wheeling:
document.getElementById('canvas').addEventListener('mousewheel',f.bind(this));
document.getElementById('canvas').addEventListener('DOMMouseScroll',f.bind(this));
function f(e){
alert(e.wheelDeltaY);
}
But, read articles like this about how that only works in some browsers, and for other approaches:
mousewheel - Event reference | MDN
Once you have a usable value you would then need more code to sensibly scale the image.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.