aboutsummaryrefslogtreecommitdiffstats
path: root/_smooziee.js
diff options
context:
space:
mode:
authoranekos2014-12-14 16:39:29 +0900
committeranekos2014-12-14 16:39:29 +0900
commit4c20fd12fe9a286ff8e4b5423c694d79dac45b0c (patch)
treef6940095050d32b81009528b1344b83b4e8332e8 /_smooziee.js
parentc2ede41a905425bfc0348b248dbb370f40e0937f (diff)
downloadvimperator-plugins-4c20fd12fe9a286ff8e4b5423c694d79dac45b0c.tar.bz2
Fix indentations
Diffstat (limited to '_smooziee.js')
-rw-r--r--_smooziee.js130
1 files changed, 65 insertions, 65 deletions
diff --git a/_smooziee.js b/_smooziee.js
index a545406..42eb9e3 100644
--- a/_smooziee.js
+++ b/_smooziee.js
@@ -80,80 +80,80 @@ var INFO = xml`
let self = liberator.plugins.smooziee = (function(){
- mappings.addUserMap(
- [modes.NORMAL],
- ["j"],
- "Smooth scroll down",
- function(count){
- self.smoothScrollBy(getScrollAmount());
- },
- {
- count: true
- }
- );
- mappings.addUserMap(
- [modes.NORMAL],
- ["k"],
- "Smooth scroll up",
- function(count){
- self.smoothScrollBy(getScrollAmount() * -1);
- },
- {
- count: true
- }
- );
-
- var next;
- var win;
- var interval;
-
- var PUBLICS = {
- smoothScrollBy: function(moment) {
- win = Buffer.findScrollableWindow();
- interval = window.eval(liberator.globalVariables.smooth_scroll_interval || '30');
- clearTimeout(next);
- smoothScroll(moment);
- }
+ mappings.addUserMap(
+ [modes.NORMAL],
+ ["j"],
+ "Smooth scroll down",
+ function(count){
+ self.smoothScrollBy(getScrollAmount());
+ },
+ {
+ count: true
}
-
- function logBase(x, y) {
- // Logarithm of arbitrary base `x`
- return Math.log(y) / Math.log(x);
+ );
+ mappings.addUserMap(
+ [modes.NORMAL],
+ ["k"],
+ "Smooth scroll up",
+ function(count){
+ self.smoothScrollBy(getScrollAmount() * -1);
+ },
+ {
+ count: true
}
+ );
- function getScrollAmount() {
- // see recognition of Fibonacci Numbers (here approximation is used)
- // http://en.wikipedia.org/wiki/Fibonacci_number#Recognizing_Fibonacci_numbers
- phi = 1.618033;
- sqrt5 = 2.236067;
- fn = liberator.globalVariables.smooth_scroll_amount || '150'
- n = Math.ceil(logBase(phi, (fn * sqrt5 + Math.sqrt(5 * Math.pow(fn, 2) + 4)) / 2))
- return window.eval(n);
- }
+ var next;
+ var win;
+ var interval;
- function fib(n){
- // see optimized Binet's formula for Fibonacci sequence
- // http://en.wikipedia.org/wiki/Fibonacci_number#Closed_form_expression
- phi = 1.618033;
- sqrt5 = 2.236067;
- return Math.floor((Math.pow(phi, n) / sqrt5) + 0.5)
+ var PUBLICS = {
+ smoothScrollBy: function(moment) {
+ win = Buffer.findScrollableWindow();
+ interval = window.eval(liberator.globalVariables.smooth_scroll_interval || '30');
+ clearTimeout(next);
+ smoothScroll(moment);
}
+ }
- function smoothScroll(moment) {
- if (moment > 0) {
- moment = moment - 1;
- win.scrollBy(0, fib(Math.abs(moment)));
- } else {
- moment = moment + 1;
- win.scrollBy(0, -fib(Math.abs(moment)));
- }
+ function logBase(x, y) {
+ // Logarithm of arbitrary base `x`
+ return Math.log(y) / Math.log(x);
+ }
- if (moment == 0)
- return;
+ function getScrollAmount() {
+ // see recognition of Fibonacci Numbers (here approximation is used)
+ // http://en.wikipedia.org/wiki/Fibonacci_number#Recognizing_Fibonacci_numbers
+ phi = 1.618033;
+ sqrt5 = 2.236067;
+ fn = liberator.globalVariables.smooth_scroll_amount || '150'
+ n = Math.ceil(logBase(phi, (fn * sqrt5 + Math.sqrt(5 * Math.pow(fn, 2) + 4)) / 2))
+ return window.eval(n);
+ }
- next = setTimeout(function() smoothScroll(moment), interval);
+ function fib(n){
+ // see optimized Binet's formula for Fibonacci sequence
+ // http://en.wikipedia.org/wiki/Fibonacci_number#Closed_form_expression
+ phi = 1.618033;
+ sqrt5 = 2.236067;
+ return Math.floor((Math.pow(phi, n) / sqrt5) + 0.5)
+ }
+
+ function smoothScroll(moment) {
+ if (moment > 0) {
+ moment = moment - 1;
+ win.scrollBy(0, fib(Math.abs(moment)));
+ } else {
+ moment = moment + 1;
+ win.scrollBy(0, -fib(Math.abs(moment)));
}
- return PUBLICS;
+ if (moment == 0)
+ return;
+
+ next = setTimeout(function() smoothScroll(moment), interval);
+ }
+
+ return PUBLICS;
})();
// vim: sw=2 ts=2 et si fdm=marker: