mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 16:47:59 +01:00
Move smooth-scroll plugin to the core.
This commit is contained in:
@@ -523,7 +523,7 @@ dactylUtils::LoadSubScript (const PRUnichar * aURL
|
|||||||
|
|
||||||
nsCAutoString cachePath;
|
nsCAutoString cachePath;
|
||||||
cachePath.Append("jssubloader/");
|
cachePath.Append("jssubloader/");
|
||||||
cachePath.Append(version);
|
cachePath.AppendInt(version);
|
||||||
if (charset) {
|
if (charset) {
|
||||||
cachePath.Append("/");
|
cachePath.Append("/");
|
||||||
cachePath.Append(NS_ConvertUTF16toUTF8(
|
cachePath.Append(NS_ConvertUTF16toUTF8(
|
||||||
|
|||||||
@@ -1326,6 +1326,9 @@ var Buffer = Module("buffer", {
|
|||||||
if (~[elem, elem.document, elem.ownerDocument].indexOf(buffer.focusedFrame.document))
|
if (~[elem, elem.document, elem.ownerDocument].indexOf(buffer.focusedFrame.document))
|
||||||
marks.push(reason);
|
marks.push(reason);
|
||||||
|
|
||||||
|
if (options["scrollsteps"] > 1)
|
||||||
|
return this.smoothScrollTo(elem, left, top);
|
||||||
|
|
||||||
elem = Buffer.Scrollable(elem);
|
elem = Buffer.Scrollable(elem);
|
||||||
if (left != null)
|
if (left != null)
|
||||||
elem.scrollLeft = left;
|
elem.scrollLeft = left;
|
||||||
@@ -1338,6 +1341,39 @@ var Buffer = Module("buffer", {
|
|||||||
.redraw();
|
.redraw();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like scrollTo, but scrolls more smoothly and does not update
|
||||||
|
* marks.
|
||||||
|
*/
|
||||||
|
smoothScrollTo: function smoothScrollTo(elem, x, y) {
|
||||||
|
let time = options["scrolltime"];
|
||||||
|
let steps = options["scrollsteps"];
|
||||||
|
|
||||||
|
let data = elem;
|
||||||
|
elem = Buffer.Scrollable(elem);
|
||||||
|
|
||||||
|
if (data.dactylScrollTimer)
|
||||||
|
data.dactylScrollTimer.cancel();
|
||||||
|
|
||||||
|
x = data.dactylScrollDestX = Math.min(x, elem.scrollWidth - elem.clientWidth);
|
||||||
|
y = data.dactylScrollDestY = Math.min(y, elem.scrollHeight - elem.clientHeight);
|
||||||
|
let [startX, startY] = [elem.scrollLeft, elem.scrollTop];
|
||||||
|
let n = 0;
|
||||||
|
(function next() {
|
||||||
|
if (n++ === steps) {
|
||||||
|
elem.scrollLeft = x;
|
||||||
|
elem.scrollTop = y;
|
||||||
|
delete data.dactylScrollDestX;
|
||||||
|
delete data.dactylScrollDestY;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
elem.scrollLeft = startX + (x - startX) / steps * n;
|
||||||
|
elem.scrollTop = startY + (y - startY) / steps * n;
|
||||||
|
data.dactylScrollTimer = util.timeout(next, time / steps);
|
||||||
|
}
|
||||||
|
}).call(this);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls the currently given element horizontally.
|
* Scrolls the currently given element horizontally.
|
||||||
*
|
*
|
||||||
@@ -1353,6 +1389,7 @@ var Buffer = Module("buffer", {
|
|||||||
scrollHorizontal: function scrollHorizontal(elem, unit, number) {
|
scrollHorizontal: function scrollHorizontal(elem, unit, number) {
|
||||||
let fontSize = parseInt(DOM(elem).style.fontSize);
|
let fontSize = parseInt(DOM(elem).style.fontSize);
|
||||||
|
|
||||||
|
let data = elem;
|
||||||
elem = Buffer.Scrollable(elem);
|
elem = Buffer.Scrollable(elem);
|
||||||
let increment;
|
let increment;
|
||||||
if (unit == "columns")
|
if (unit == "columns")
|
||||||
@@ -1364,8 +1401,8 @@ var Buffer = Module("buffer", {
|
|||||||
|
|
||||||
dactyl.assert(number < 0 ? elem.scrollLeft > 0 : elem.scrollLeft < elem.scrollWidth - elem.clientWidth);
|
dactyl.assert(number < 0 ? elem.scrollLeft > 0 : elem.scrollLeft < elem.scrollWidth - elem.clientWidth);
|
||||||
|
|
||||||
let left = elem.dactylScrollDestX !== undefined ? elem.dactylScrollDestX : elem.scrollLeft;
|
let left = data.dactylScrollDestX !== undefined ? data.dactylScrollDestX : elem.scrollLeft;
|
||||||
elem.dactylScrollDestX = undefined;
|
data.dactylScrollDestX = undefined;
|
||||||
|
|
||||||
Buffer.scrollTo(elem, left + number * increment, null, "h-" + unit);
|
Buffer.scrollTo(elem, left + number * increment, null, "h-" + unit);
|
||||||
},
|
},
|
||||||
@@ -1385,6 +1422,7 @@ var Buffer = Module("buffer", {
|
|||||||
scrollVertical: function scrollVertical(elem, unit, number) {
|
scrollVertical: function scrollVertical(elem, unit, number) {
|
||||||
let fontSize = parseInt(DOM(elem).style.lineHeight);
|
let fontSize = parseInt(DOM(elem).style.lineHeight);
|
||||||
|
|
||||||
|
let data = elem;
|
||||||
elem = Buffer.Scrollable(elem);
|
elem = Buffer.Scrollable(elem);
|
||||||
let increment;
|
let increment;
|
||||||
if (unit == "lines")
|
if (unit == "lines")
|
||||||
@@ -1396,8 +1434,8 @@ var Buffer = Module("buffer", {
|
|||||||
|
|
||||||
dactyl.assert(number < 0 ? elem.scrollTop > 0 : elem.scrollTop < elem.scrollHeight - elem.clientHeight);
|
dactyl.assert(number < 0 ? elem.scrollTop > 0 : elem.scrollTop < elem.scrollHeight - elem.clientHeight);
|
||||||
|
|
||||||
let top = elem.dactylScrollDestY !== undefined ? elem.dactylScrollDestY : elem.scrollTop;
|
let top = data.dactylScrollDestY !== undefined ? data.dactylScrollDestY : elem.scrollTop;
|
||||||
elem.dactylScrollDestY = undefined;
|
data.dactylScrollDestY = undefined;
|
||||||
|
|
||||||
Buffer.scrollTo(elem, null, top + number * increment, "v-" + unit);
|
Buffer.scrollTo(elem, null, top + number * increment, "v-" + unit);
|
||||||
},
|
},
|
||||||
@@ -2234,6 +2272,28 @@ var Buffer = Module("buffer", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
options.add(["scrolltime", "st"],
|
||||||
|
"The time, in milliseconds, in which to smooth scroll to a new position",
|
||||||
|
"number", 100);
|
||||||
|
|
||||||
|
options.add(["scrollsteps", "ss"],
|
||||||
|
"The number of steps in which to smooth scroll to a new position",
|
||||||
|
"number", 5,
|
||||||
|
{
|
||||||
|
PREF: "general.smoothScroll",
|
||||||
|
|
||||||
|
initValue: function () {},
|
||||||
|
|
||||||
|
getter: function getter(value) !prefs.get(this.PREF) ? 1 : value,
|
||||||
|
|
||||||
|
setter: function setter(value) {
|
||||||
|
prefs.set(this.PREF, value > 1);
|
||||||
|
return value > 1 ? value : this.globalValue;
|
||||||
|
},
|
||||||
|
|
||||||
|
validator: function (value) value > 0
|
||||||
|
});
|
||||||
|
|
||||||
options.add(["usermode", "um"],
|
options.add(["usermode", "um"],
|
||||||
"Show current website without styling defined by the author",
|
"Show current website without styling defined by the author",
|
||||||
"boolean", false,
|
"boolean", false,
|
||||||
|
|||||||
@@ -1381,6 +1381,28 @@
|
|||||||
</description>
|
</description>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<tags>'ss' 'scrollsteps'</tags>
|
||||||
|
<spec>'scrollsteps' 'ss'</spec>
|
||||||
|
<type>&option.scrollsteps.type;</type>
|
||||||
|
<default>&option.scrollsteps.default;</default>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
The number of steps in which to smooth scroll to a new position. If
|
||||||
|
set to 1, smooth scrolling is not used.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<tags>'st' 'scrolltime'</tags>
|
||||||
|
<spec>'scrolltime' 'st'</spec>
|
||||||
|
<type>&option.scrolltime.type;</type>
|
||||||
|
<default>&option.scrolltime.default;</default>
|
||||||
|
<description>
|
||||||
|
<p>The time, in milliseconds, in which to smooth scroll to a new position.</p>
|
||||||
|
</description>
|
||||||
|
</item>
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
<tags>'spl' 'spelllang'</tags>
|
<tags>'spl' 'spelllang'</tags>
|
||||||
<spec>'spelllang' 'spl'</spec>
|
<spec>'spelllang' 'spl'</spec>
|
||||||
|
|||||||
@@ -329,7 +329,11 @@ var File = Class("File", {
|
|||||||
/**
|
/**
|
||||||
* @property {nsIFileURL} Returns the nsIFileURL object for this file.
|
* @property {nsIFileURL} Returns the nsIFileURL object for this file.
|
||||||
*/
|
*/
|
||||||
get URI() services.io.newFileURI(this).QueryInterface(Ci.nsIFileURL),
|
URI: Class.Memoize(function () {
|
||||||
|
let uri = services.io.newFileURI(this).QueryInterface(Ci.nsIFileURL);
|
||||||
|
uri.QueryInterface(Ci.nsIMutable).mutable = false;
|
||||||
|
return uri;
|
||||||
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over the objects in this directory.
|
* Iterates over the objects in this directory.
|
||||||
|
|||||||
@@ -73,6 +73,7 @@
|
|||||||
• Improved [macro-string] support, including automatic elision
|
• Improved [macro-string] support, including automatic elision
|
||||||
of optional elements, and array subscripts. [b4][b7]
|
of optional elements, and array subscripts. [b4][b7]
|
||||||
• Add -pentadactyl-remote command-line option. [b8]
|
• Add -pentadactyl-remote command-line option. [b8]
|
||||||
|
• Moved the smooth-scroll plugin to the core. [b8]
|
||||||
• Improvements to marks:
|
• Improvements to marks:
|
||||||
- Marks are now stored as line and column ordinals rather than percentages. [b8]
|
- Marks are now stored as line and column ordinals rather than percentages. [b8]
|
||||||
- Marks now store the marked element and ensure its visibility when followed. [b8]
|
- Marks now store the marked element and ensure its visibility when followed. [b8]
|
||||||
@@ -218,6 +219,7 @@
|
|||||||
- Added 'passunknown' option. [b7]
|
- Added 'passunknown' option. [b7]
|
||||||
- Changed 'urlseparator' default value to "|". [b3]
|
- Changed 'urlseparator' default value to "|". [b3]
|
||||||
- Added "errorconsole", "passwords", and "venkman" dialogs to :dialog. [b2][b8]
|
- Added "errorconsole", "passwords", and "venkman" dialogs to :dialog. [b2][b8]
|
||||||
|
- Added 'scrollsteps' and 'scrolltime' options. [b8]
|
||||||
- Added 'spelllang' option. [b8]
|
- Added 'spelllang' option. [b8]
|
||||||
- Make 'showmode' a [stringlist] option. [b7]
|
- Make 'showmode' a [stringlist] option. [b7]
|
||||||
- Added 'wildanchor' option. [b2]
|
- Added 'wildanchor' option. [b2]
|
||||||
|
|||||||
Reference in New Issue
Block a user