-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from flesler/window-scroll-alt
2.0.0
- Loading branch information
Showing
14 changed files
with
88 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,21 @@ | ||
$.fn.test = function(){ | ||
if( location.search == '?notest' ) | ||
// Hide title on iframes | ||
if (window.self !== window.top) { | ||
$('h1').hide(); | ||
} | ||
|
||
if (location.search === '?notest') { | ||
return this; | ||
} | ||
|
||
testScrollable(); | ||
|
||
$.scrollTo.defaults.axis = 'xy'; | ||
|
||
this._scrollable().find('div').html( | ||
var root = this.is('iframe') ? this.contents() : $('body'); | ||
root.find('#ua').html( | ||
navigator.userAgent + | ||
'<br />' + | ||
'document.compatMode is "' + document.compatMode + '"' + | ||
'<br />' + | ||
'scrolling the ' + this._scrollable().prop('nodeName') | ||
'document.compatMode is "' + document.compatMode + '"' | ||
); | ||
|
||
/*var orig = [ $(window).scrollLeft(), $(window).scrollTop() ]; | ||
scrollTo(0,1); | ||
var elem = document.documentElement.scrollTop ? document.documentElement : document.body; | ||
scrollTo(0,9e9); | ||
var max = $(window).scrollTop(); | ||
scrollTo(orig[0],orig[1]); | ||
setTimeout(function(){ | ||
alert( elem.nodeName + ' ' + max ); | ||
}, 1000 );*/ | ||
return this.scrollTo('max', 1000).scrollTo(0, 1000) | ||
return this.scrollTo('max', 1000).scrollTo(0, 1000); | ||
}; | ||
|
||
function assert( bool, message ){ | ||
if( !bool ){ | ||
alert('FAIL: ' + message); | ||
throw new Error(); | ||
} | ||
}; | ||
|
||
function f( name ){ | ||
return $(name)[0]; | ||
} | ||
|
||
function testScrollable(){ | ||
|
||
$.each([ window, document, f('body'), f('html') ], function(i, elem){ | ||
var s = $(elem)._scrollable(); | ||
assert( s.length == 1, 'scrollable must always return exactly 1 element' ); | ||
assert( s.is('html,body'), 'scrollable must either html or body for window scrolling' ); | ||
}); | ||
|
||
$('body :not(iframe)').each(function(){ | ||
var s = $(this)._scrollable(); | ||
assert( s.length == 1, 'scrollable must always return exactly 1 element' ); | ||
assert( s[0] == this, 'scrollable must return the same element for normal element scrolling' ); | ||
}); | ||
}; | ||
|
||
$(function(){ | ||
if( location.search == '?notest' ) | ||
$('h1').hide(); | ||
}); |