X-Git-Url: https://git.shemshak.org/~bandali/configs/blobdiff_plain/215cc3c85912169c355c364f920a0c9f23456cb8..1267cee65a4bad8a3468ad8d72c1e48424fa49ec:/vimperator/.vimperator/plugin/_smooziee.js diff --git a/vimperator/.vimperator/plugin/_smooziee.js b/vimperator/.vimperator/plugin/_smooziee.js deleted file mode 100644 index a8af10d..0000000 --- a/vimperator/.vimperator/plugin/_smooziee.js +++ /dev/null @@ -1,171 +0,0 @@ -// -// _smooziee.js -// -// LICENSE: {{{ -// Copyright (c) 2009 snaka -// -// distributable under the terms of an MIT-style license. -// http://www.opensource.jp/licenses/mit-license.html -// }}} -// -// INFO: {{{ -var INFO = xml` - - snaka - - MIT style license -

j,k key scrolling to be smoothly.

-

Global vriables

-

You can configure following variable as you like.

-
-
smooziee_scroll_amount
Scrolling amount(unit:px). Default value is 400px.
-
smooziee_interval
Scrolling interval(unit:ms). Default value is 20ms.
-
-

Example

-

Set scroll amount is 300px and interval is 10ms.

- -

API

- smooziee.smoothScrollBy(amount); -

Example

- -
- - snaka - - MIT style license -

普段のj,kキーのスクロールをLDRizeライクにスムースにします。

-

グローバル変数

-

以下の変数を.vimperatorrcなどで設定することで動作を調整することができます。

-
-
smooziee_scroll_amount
-
1回にスクロールする幅です(単位:ピクセル)。デフォルトは"400"です。
-
smooziee_interval
-
スクロール時のアニメーションのインターバルです(単位:ミリ秒)。 - "1"以上の値を設定します。デフォルトは"20"です。
-
-

設定例

-

スクロール量を300pxに、インターバルを10msに設定します。

- -

API

-

他のキーにマップする場合やスクリプトから呼び出せるようAPIを用意してます。

- smooziee.smoothScrollBy(amount); -

Example

- -

ToDo

-
    -
  • 読み込みの順番によっては他のプラグインと競合する可能性があるのをなんとかしたい。
  • -
-
`; -// }}} - -let self = liberator.plugins.smooziee = (function(){ - - // Mappings {{{ -/* mappings.addUserMap( - [modes.NORMAL], - ["j"], - "Smooth scroll down", - function(count){ - self.smoothScrollBy(getScrollAmount() * (count || 1)); - }, - { - count: true - } - ); - mappings.addUserMap( - [modes.NORMAL], - ["k"], - "Smooth scroll up", - function(count){ - self.smoothScrollBy(getScrollAmount() * -(count || 1)); - }, - { - count: true - } - ); -*/ - - mappings.addUserMap( - [modes.NORMAL], - ["d"], - "Smooth scroll down page", - function(count){ - self.smoothScrollBy(getScrollAmount() * 3.5 * (count || 1)); - }, - { - count: true - } - ); - mappings.addUserMap( - [modes.NORMAL], - ["u"], - "Smooth scroll up page", - function(count){ - self.smoothScrollBy(getScrollAmount() * 3.5 * -(count || 1)); - }, - { - count: true - } - ); - // }}} - // PUBLIC {{{ - var PUBLICS = { - smoothScrollBy: function(moment) { - win = Buffer.findScrollableWindow(); - interval = window.eval(liberator.globalVariables.smooziee_scroll_interval || '20'); - destY = win.scrollY + moment; - clearTimeout(next); - smoothScroll(moment); - } - } - - // }}} - // PRIVATE {{{ - var next; - var destY; - var win; - var interval; - - function getScrollAmount() window.eval(liberator.globalVariables.smooziee_scroll_amount || '400'); - - function smoothScroll(moment) { - if (moment > 0) - moment = Math.floor(moment / 2); - else - moment = Math.ceil(moment / 2); - - win.scrollBy(0, moment); - - if (Math.abs(moment) < 1) { - setTimeout(makeScrollTo(win.scrollX, destY), interval); - destY = null; - return; - } - next = setTimeout(function() smoothScroll(moment), interval); - } - - function makeScrollTo(x, y) function() win.scrollTo(x, y); - // }}} - return PUBLICS; -})(); -// vim: sw=2 ts=2 et si fdm=marker: