快捷键功能完善
1)使用的快捷键插件:keypress-2.1.4.min.js
2)键盘的向上向下键盘,选择元素
/**
*up:键盘的向上
*down:键盘的向下
*/
function up(obj,isChild){
obj.removeClass("selected");
var prev = obj.prev();
prev.addClass('selected');
}
function down(obj,isChild){
obj.removeClass("selected");
var next = obj.next();
next.addClass('selected');
}
** hidden(prev,'up'); up_down_event(prev,isChild);代码可忽略(业务方面内容)
3)检测元素是否在可视区域 有滚动条
function hidden(obj,forword){
var scrollWin = obj.parents('.gridScroller');
var itemOffsetTop = obj.offset().top;
var itemOuterHeight = obj.outerHeight();
var winHeight = scrollWin.height();
var winOffsetTop = scrollWin.offset().top;
var scrolledHeight = scrollWin.scrollTop();
var visibleHight = winHeight + winOffsetTop;
var currentItemHeight = itemOffsetTop + itemOuterHeight;
if(forword == 'down'){
if(visibleHight < currentItemHeight){
//to do
scrollWin.scrollTop(itemOuterHeight + scrolledHeight);
}
}else{//up
currentItemHeight = currentItemHeight + scrolledHeight;
if(visibleHight > currentItemHeight){
//to do
scrollWin.scrollTop(scrolledHeight - itemOuterHeight);
}
}
}
ps:附件是快捷键的插件以及自己封装的功能实现。
上一篇: 比较全面的idea快捷键总结和一些注释
下一篇: Java第五课——运算符