Действия колесиком мышки
Всем привет. Сегодня я сделаю обзор интересного плагина для управления значениями полей форм с помощью колесика мышки. Решения мне нравится тем, что некоторые формы можно будет заполнять только с помощью мышки, а это выглядит просто классно.
Теперь перейдем к технической реализации. Для этого на понадобится jQuery и пара плагинов к нему, такиех как MouseWheel Plugin и небольшому плагину от css trick.
Для начала создадим поле с которым мы будем работать:
<div>
<label for="how-many">How Many? </label>
<input type="text" id="how-many" class="wheelable" value="1" name="how-many" />
</div>
Теперь подключим все необходимы javascript библиотеки:
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
<script type="text/javascript" src="js/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="js/increment.js"></script>
Теперь применим к нашему полю эти скрипты:
$(function() {
$("div").append('<img src="images/mousewheelupdown.png" alt="Scroll up or down with mousewheel" />');
$("#how-many").bind("mousewheel", function(event, delta) {
if (delta > 0) {
this.value = parseInt(this.value) + 1;
}
else {
if (parseInt(this.value) > 0) {
this.value = parseInt(this.value) - 1;
}
} return false; });
});
Готово! Все работает, сами смотрите что вышло.
Так же можно изменять не только численные значения:
$("#whale").bind("mousewheel", function(event, delta) {
if (this.value == "Blue") {
this.value = "Sperm";
}
else if (this.value == "Sperm") {
this.value = "Orca";
}
else if (this.value == "Orca") {
this.value = "Humpback";
}
else if (this.value == "Humpback") {
this.value = "Blue"; } return false;
});
Так что это можно использовать почти в любой вашей форме.
Думаю, применить к своим проектам данные наработки не составит труда - зато такая приятная мелочь для пользователей!


I am very happy to read this. This is the kind of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this greatest doc.
you are in point of fact a good webmaster. The site loading speed is amazing. It sort of feels that you’re doing any unique trick. In addition, The contents are masterwork. you have performed a magnificent task in this topic!
thx for this post ! very informative !
Have you thought about including some social bookmarking buttons to these blogs. At least for google.
Thanks for writing this. I really feel as though I know so much more about this than I did before. Your blog really brought some things to light that I never would have thought about before reading it. You should continue this, Im sure most people would agree youve got a gift.
Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is wonderful blog. An excellent read. I will certainly be back.
hello there and thank you for your info – I’ve definitely picked up anything new from right here. I did however expertise several technical issues using this site, since I experienced to reload the site lots of times previous to I could get it to load correctly. I had been wondering if your hosting is OK? Not that I am complaining, but sluggish loading instances times will very frequently affect your placement in google and can damage your quality score if advertising and marketing with Adwords. Anyway I’m adding this RSS to my e-mail and can look out for a lot more of your respective interesting content. Ensure that you update this again very soon..
Youre so awesome, man! I cant believe I missed this blog for so long. Its just great stuff all round. Your design, man…too amazing! I cant wait to read what youve got next. I love everything that youre saying and want more, more, MORE! Keep this up, man! Its just too good.
I in addition to my guys were found to be reviewing the great tips located on your site and so the sudden got a horrible suspicion I had not thanked the site owner for those strategies. The young men are already consequently warmed to see all of them and have in effect simply been taking advantage of them. Thank you for getting indeed accommodating and also for deciding on this form of extraordinary useful guides millions of individuals are really needing to understand about. My very own honest regret for not expressing gratitude to you earlier.
Just wanna comment on few general things, The website design and style is perfect, the content material is rattling wonderful : D.
You have observed very interesting details ! ps decent web site . «I understand a fury in your words, But not the words.» by William Shakespeare.
It¡¦s actually a nice and helpful piece of info. I am happy that you just shared this useful info with us. Please keep us up to date like this. Thank you for sharing.
Hello there and good day! Excuse me as my english is just not very good, however I’ve to say that the submission may be very insightful indeed. Thank you for the info, and if you are keen, can we trade links too? Let me know.
Awseome article, I am a big believer in placing comments on blogs to help the blog writers know that they’ve added some thing advantageous to the world wide web!
Hello! I’ve been following your web site for some time now and finally got the bravery to go ahead and give you a shout out from New Caney Texas! Just wanted to mention keep up the fantastic work!
Value this website. Which is almost all I will declare. Anyone certainly create this site in to one thing that is eye-sight beginning plus crucial. Anybody naturally understand a lot about the subject, you’ve included several bottoms. Great merchandise by using this the key world wide web. Once more, appreciate your this website.