This commit is contained in:
noririty%jcom.home.ne.jp 2003-07-25 04:13:46 +00:00
Родитель 042b7cacc7
Коммит 5c7f57e38a
1 изменённых файлов: 96 добавлений и 125 удалений

Просмотреть файл

@ -438,30 +438,50 @@
</method> </method>
#ifdef XP_WIN #ifdef XP_WIN
<field name="_scrollObj">null</field> <field name="_AUTOSCROLL_SPEED">3</field>
<field name="_AUTOSCROLL_SNAP">10</field>
<field name="_clientFrameDoc">null</field>
<field name="_clientFrameBody">null</field>
<field name="_isScrolling">false</field> <field name="_isScrolling">false</field>
<field name="_autoScrollMarkerImage">null</field> <field name="_autoScrollMarkerImage">null</field>
<field name="_scrollingFingerFree">false</field> <field name="_snapOn">false</field>
<field name="_scrollPeriod">40</field> <field name="_scrollCount">0</field>
<field name="_scrollInterval">null</field>
<field name="_startX">null</field> <field name="_startX">null</field>
<field name="_distanceX">null</field>
<field name="_startY">null</field> <field name="_startY">null</field>
<field name="_distanceY">null</field> <field name="_clientX">null</field>
<field name="_startTime">null</field> <field name="_clientY">null</field>
<method name="autoScrollLoop1"> <method name="stopScroll">
<body> <body>
<![CDATA[ <![CDATA[
this._scrollObj.clientFrame.scrollBy(this._distanceX, this._distanceY); this._isScrolling = false;
if (this._autoScrollMarkerImage) {
this._autoScrollMarkerImage.style.display = 'none'; // seems to avoid blocking when autoscroll is initited during pageload
this._autoScrollMarkerImage.parentNode.removeChild(this._autoScrollMarkerImage);
}
this._autoScrollMarkerImage = null;
]]> ]]>
</body> </body>
</method> </method>
<method name="autoScrollLoop2">
<method name="autoScrollLoop">
<body> <body>
<![CDATA[ <![CDATA[
this._scrollObj.nodeToScroll.scrollLeft += this._distanceX; if (this._isScrolling) {
this._scrollObj.nodeToScroll.scrollTop += this._distanceY; var x = (this._clientX - this._startX) / this._AUTOSCROLL_SPEED;
var y = (this._clientY - this._startY) / this._AUTOSCROLL_SPEED;
if(Math.abs(x) > 0 && Math.abs(y) > 0)
{
if (this._scrollCount++ % 2)
y = 0;
else
x = 0;
}
this._clientFrameDoc.defaultView.scrollBy(x, y);
setTimeout(function foo(a) { a.autoScrollLoop() }, 5, this);
}
]]> ]]>
</body> </body>
</method> </method>
@ -470,7 +490,11 @@
<body> <body>
<![CDATA[ <![CDATA[
if (!node) return false; if (!node) return false;
if (node.nodeName == "A" || node.nodeName == "AREA") return true; if (node.nodeName == "A" || node.nodeName == "INPUT" || node.nodeName == "TEXTAREA" ||
node.nodeName == "AREA") {
return true;
}
return this.isLink(node.parentNode); return this.isLink(node.parentNode);
]]> ]]>
</body> </body>
@ -479,69 +503,43 @@
<parameter name="evt"/> <parameter name="evt"/>
<body> <body>
<![CDATA[ <![CDATA[
function scrollCursorType(neededW, availW, neededH, availH, scrollBarSize) { var scrollCursor = new Array("move", "n-resize", "e-resize");
if (neededW <= availW && neededH <= availH) return 3; var docBox = this._clientFrameDoc.getBoxObjectFor(this._clientFrameDoc.documentElement);
if (neededW > availW && neededH > availH) return 0; var left = evt.screenX - docBox.screenX;
if (neededW > availW) return ((neededH <= (availH - scrollBarSize)) - 0) << 1; // 0 or 2 var top = evt.screenY - docBox.screenY;
return (neededW <= (availW - scrollBarSize)) - 0;
}
var initialNode = evt.originalTarget;
var targetDoc = initialNode.ownerDocument;
var docEl = targetDoc.documentElement;
var insertionNode = (docEl) ? docEl : targetDoc;
var docBox = targetDoc.getBoxObjectFor(insertionNode);
this._scrollObj = {scrollType: 3, isXML: false, nodeToScroll: null, clientFrame: null};
var nextNode = initialNode, currNode;
if (docEl && docEl.nodeName.toLowerCase() == "html") { // walk the tree up looking for something to scroll
do
try {
currNode = nextNode;
nextNode = currNode.parentNode;
if (currNode.clientWidth && currNode.clientHeight) {
this._scrollObj.scrollType = scrollCursorType(currNode.scrollWidth, currNode.clientWidth,
currNode.scrollHeight, currNode.clientHeight, 0);
if (this._scrollObj.scrollType != 3) break;
}
}
catch(err) {}
while (currNode && currNode != docEl);
this._scrollObj.nodeToScroll = currNode;
}
else { // XML document; do our best
this._scrollObj.clientFrame = initialNode.ownerDocument.defaultView;
var renderingArea = document.getElementById("content").mPanelContainer;
if (docBox) this._scrollObj.scrollType = scrollCursorType(docBox.width, renderingArea.boxObject.width, docBox.height, renderingArea.boxObject.height, 16);
this._scrollObj.isXML = true;
}
if (this._scrollObj.scrollType == 3) { // nothing to scroll
this._scrollingFingerFree = true; // exit on next mouse up var documentWidth = docBox.width;
return 2; var documentHeight = docBox.height;
} var windowWidth = window.innerWidth;
const scrollCursor = ["move", "n-resize", "e-resize"]; var windowHeight = window.innerHeight;
const scrollImages = ["chrome://global/content/widgets/autoscroll_all.png", var scrollType = 0;
"chrome://global/content/widgets/autoscroll_v.png", if (windowHeight < documentHeight && windowWidth >= documentWidth)
"chrome://global/content/widgets/autoscroll_h.png"]; scrollType = 1;
const imageWidth = 28; else if (windowHeight >= documentHeight && windowWidth < documentWidth)
const imageHeight = 28; scrollType = 2;
var imageWidth = 28;
var imageHeight = 28;
// marker // marker
var el = targetDoc.createElementNS("http://www.w3.org/1999/xhtml", "img"); var el = this._clientFrameDoc.createElementNS("http://www.w3.org/1999/xhtml", "img");
el.src = scrollImages[this._scrollObj.scrollType];
var scrollImages = new Array("chrome://global/content/widgets/autoscroll_all.png",
"chrome://global/content/widgets/autoscroll_v.png",
"chrome://global/content/widgets/autoscroll_h.png");
el.src = scrollImages[scrollType];
el.style.position = "fixed"; el.style.position = "fixed";
el.style.left = evt.screenX - docBox.screenX - imageWidth / 2 + "px"; el.style.left = left - imageWidth / 2 + "px";
el.style.top = evt.screenY - docBox.screenY - imageHeight / 2 + "px"; el.style.top = top - imageHeight / 2 + "px";
el.style.width = imageWidth + "px"; el.style.width = imageWidth + "px";
el.style.height = imageHeight + "px"; el.style.height = imageHeight + "px";
el.style.border = "0px"; el.style.cursor = scrollCursor[scrollType];
el.style.zIndex = 10000;
el.style.cursor = scrollCursor[this._scrollObj.scrollType]; this._clientFrameBody.appendChild(el);
insertionNode.appendChild(el);
this._autoScrollMarkerImage = el; this._autoScrollMarkerImage = el;
return this._scrollObj.isXML - 0;
]]> ]]>
</body> </body>
</method> </method>
@ -596,70 +594,43 @@
#ifdef XP_WIN #ifdef XP_WIN
<handler event="mouseup"> <handler event="mouseup">
<![CDATA[ <![CDATA[
if (!this._isScrolling) return; if (!this._snapOn)
event.preventDefault(); event.stopPropagation(); this.stopScroll();
if (this._scrollingFingerFree || (event.timeStamp - this._startTime) > 500) {
if (this._scrollInterval) window.clearInterval(this._scrollInterval);
this._scrollInterval = null;
this._isScrolling = false;
if (this._autoScrollMarkerImage) {
this._autoScrollMarkerImage.style.display = 'none'; // seems to avoid blocking when autoscroll is initited during pageload
this._autoScrollMarkerImage.parentNode.removeChild(this._autoScrollMarkerImage);
}
this._autoScrollMarkerImage = null;
}
else this._scrollingFingerFree = true;
]]> ]]>
</handler> </handler>
<handler event="mousedown"> <handler event="mousedown">
<![CDATA[ <![CDATA[
if (this.getAttribute("autoscroll") != "false" && !this._isScrolling && event.button == 1 && !this.isLink(event.originalTarget)) { if (this.getAttribute("autoscroll") == "false" || this.isLink(event.originalTarget))
this._startX = event.clientX; this._startY = event.clientY; return;
this._distanceX = 0; this._distanceY = 0;
this._scrollingFingerFree = false; if (!this._isScrolling) {
this._startTime = event.timeStamp; if (event.button == 1) {
event.preventDefault(); event.stopPropagation(); this._startX = event.clientX;
switch (this.showAutoscrollMarker(event)) { this._startY = event.clientY;
case 0: this._scrollInterval = window.setInterval(function foo(a) {a.autoScrollLoop2()}, this._scrollPeriod, this); this._clientFrameDoc = event.originalTarget.ownerDocument;
this._isScrolling = true; this._clientFrameBody = (this._clientFrameDoc.getElementsByTagName('body')[0]) ? this._clientFrameDoc.getElementsByTagName('body')[0] : this._clientFrameDoc.getElementsByTagName('*')[0];
break; this._isScrolling = true;
case 1: this._scrollInterval = window.setInterval(function foo(a) {a.autoScrollLoop1()}, this._scrollPeriod, this); this._snapOn = true;
this._isScrolling = true; this.showAutoscrollMarker(event);
break; window.setTimeout(function foo(a) { a.autoScrollLoop() }, 5, this);
case 2: ;
} }
} }
else {
stopScroll();
}
]]> ]]>
</handler> </handler>
<handler event="mousemove"> <handler event="mousemove">
<![CDATA[ <![CDATA[
function logDistance(aDist) { this._clientX = event.clientX;
const dist = [0, 20, 40, 60, 80, 100, 130, 180, 300, 5000]; this._clientY = event.clientY;
const ratio = [0, .067, .083, .108, .145, .2, .3, .45, .65, .9];
const sofar = [0, 0, 1.34, 3, 5.16, 8.06, 12.06, 21.06, 43.56, 121.56];
var absDistance = Math.abs(aDist);
for (var i = 1; i < dist.length; ++i)
if (absDistance < dist[i]) {
absDistance = Math.round(sofar[i] + (absDistance - dist[i-1]) * ratio[i]);
break;
}
return (aDist < 0) ? -absDistance : absDistance;
}
if (this._isScrolling) { if (this._isScrolling) {
var dX = event.clientX - this._startX; var x = this._clientX - this._startX;
var dY = event.clientY - this._startY; var y = this._clientY - this._startY;
this._distanceX = 0; this._distanceY = 0;
switch (this._scrollObj.scrollType) { if ((x > this._AUTOSCROLL_SNAP || x < -this._AUTOSCROLL_SNAP) || (y > this._AUTOSCROLL_SNAP || y < -this._AUTOSCROLL_SNAP))
case 0: if (Math.abs(dX) > Math.abs(dY)) this._distanceX = logDistance(dX); // diagonal scrolling is jerky; never do it this._snapOn = false;
else this._distanceY = logDistance(dY);
break;
case 1: this._distanceY = logDistance(dY);
break;
case 2: this._distanceX = logDistance(dX);
break;
case 3: ;
}
} }
]]> ]]>
</handler> </handler>