admin管理员组文章数量:1352849
I would like to be able to change the width of my div using the mousewheel.
I guess this is very hard to do (at least to hard for me), but I thought maybe someone has ever written such a jquery or javascript code.
To put in some context: here is the relevant part of my website: /
And here is the plete website. I would like the user to decide how big the #main div
is going to be.
I would like to be able to change the width of my div using the mousewheel.
I guess this is very hard to do (at least to hard for me), but I thought maybe someone has ever written such a jquery or javascript code.
To put in some context: here is the relevant part of my website: http://jsfiddle/XGERP/1/
And here is the plete website. I would like the user to decide how big the #main div
is going to be.
2 Answers
Reset to default 8Here's some jquery to tickle your fancy. Tested to work in Chrome, Firefox, and IE11.
$(document).ready(function(){
$('#main').bind('wheel mousewheel', function(e){
var delta;
if (e.originalEvent.wheelDelta !== undefined)
delta = e.originalEvent.wheelDelta;
else
delta = e.originalEvent.deltaY * -1;
if(delta > 0) {
$("#main").css("width", "+=10");
}
else{
$("#main").css("width", "-=10");
}
});
});
You could use Jquery Zoom...
http://www.jacklmoore./zoom/
Then just as the user hovers, they can read a bit closer...
Not sure if it would work with text though, haven't really looked into it
Or you could do something like this...
$('#main').mousewheel(function(event, delta) {
var delta_px = delta > 0 ? "+=50" : "-=50";
$(this).css('width', delta_px);
});
You need the mousewheel
extension plugin for that...
http://archive.plugins.jquery./project/mousewheel
Heres a working demo, the mousewheel script is above everything, then the actual jquery you want is at the bottom
DEMO HERE
本文标签: javascriptjquery mousewheel zoom (changing width of div)Stack Overflow
版权声明:本文标题:javascript - jquery mousewheel zoom (changing width of div) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743874911a2554152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论