From 736f14537db10911c2aaa76997377c5d3f182445 Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 19 Aug 2008 13:17:14 +0000 Subject: 逆向きのコマンドも追加 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@17907 d0d07461-0603-4401-acd4-de1884942a52 --- scroll_div.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'scroll_div.js') diff --git a/scroll_div.js b/scroll_div.js index 3eb57cf..7d71310 100644 --- a/scroll_div.js +++ b/scroll_div.js @@ -52,10 +52,12 @@ } // スクロール対象を変更 - function shiftScrollElement () { + function shiftScrollElement (n) { let idx = content.document.__div_scroller_index || 0; let es = scrollableElements(); - idx++; + idx += (n || 1); + if (idx < 0) + idx = es.length - 1; if (idx >= es.length) idx = 0; content.document.__div_scroller_index = idx; @@ -87,15 +89,26 @@ function () scroll(30) ); + liberator.mappings.addUserMap( + [liberator.modes.NORMAL], + ['k'], + 'Scroll up', + function () scroll(-30) + ); + liberator.mappings.addUserMap( [liberator.modes.NORMAL], [']d'], 'Shift Scroll Element', - function () shiftScrollElement() + function () shiftScrollElement(1) ); - scroll(100); - + liberator.mappings.addUserMap( + [liberator.modes.NORMAL], + ['[d'], + 'Shift Scroll Element', + function () shiftScrollElement(-1) + ); })(); -- cgit v1.2.3