Skip to content

Commit dea8dc1

Browse files
committed
1 parent 43b6bf8 commit dea8dc1

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

scrolltofixed/scrolltofixed-tests.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/// <reference path="scrolltofixed.d.ts" />
2+
3+
$(document).ready(function() {
4+
$('#mydiv').scrollToFixed();
5+
});
6+
7+
$(document).ready(function() {
8+
$('.header').scrollToFixed({
9+
preFixed: function() { $(this).find('h1').css('color', 'blue'); },
10+
postFixed: function() { $(this).find('h1').css('color', ''); }
11+
});
12+
13+
$('.footer').scrollToFixed( {
14+
bottom: 0,
15+
limit: $('.footer').offset().top,
16+
preFixed: function() { $(this).find('h1').css('color', 'blue'); },
17+
postFixed: function() { $(this).find('h1').css('color', ''); }
18+
});
19+
20+
// Order matters because our summary limit is based on the position
21+
// of the footer. On window refresh, the summary needs to recalculate
22+
// after the footer.
23+
$('#summary').scrollToFixed({
24+
marginTop: $('.header').outerHeight() + 10,
25+
limit: function() {
26+
var limit = $('.footer').offset().top - $('#summary').outerHeight(true) - 10;
27+
return limit;
28+
},
29+
zIndex: 999,
30+
preFixed: function() { $(this).find('.title').css('color', 'blue'); },
31+
preAbsolute: function() { $(this).find('.title').css('color', 'red'); },
32+
postFixed: function() { $(this).find('.title').css('color', ''); },
33+
postAbsolute: function() { $(this).find('.title').css('color', ''); }
34+
});
35+
});

scrolltofixed/scrolltofixed.d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Type definitions for ScrollToFixed
2+
// Project: https://github.com/bigspotteddog/ScrollToFixed
3+
// Definitions by: Ben Dixon <https://github.com/bmdixon>
4+
// Definitions: https://github.com/borisyankov/DefinitelyTyped
5+
6+
/// <reference path="../jquery/jquery.d.ts" />
7+
8+
declare module ScrollToFixed {
9+
interface ScrollToFixedOptions {
10+
marginTop? : number | (() => number);
11+
limit? : number | (() => number);
12+
bottom?: number;
13+
zIndex? : number;
14+
spacerClass? : string;
15+
preFixed?: () => void;
16+
fixed?: () => void;
17+
postFixed?: () => void;
18+
preUnfixed?: () => void;
19+
unfixed?: () => void;
20+
postUnfixed?: () => void;
21+
preAbsolute?: () => void;
22+
postAbsolute?: () => void;
23+
offsets? : boolean;
24+
minWidth? : number;
25+
maxWidth? : number;
26+
dontCheckForPositionFixedSupport? : boolean;
27+
dontSetWidth? : boolean;
28+
removeOffsets? : boolean;
29+
}
30+
}
31+
32+
interface JQuery {
33+
isScrollToFixed(el: Element) : JQuery;
34+
isScrollToFixed(el: Element[]) : JQuery;
35+
isScrollToFixed(el: {}) : JQuery;
36+
isScrollToFixed(el: JQuery) : JQuery;
37+
ScrollToFixed(el : Element, options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
38+
ScrollToFixed(el: Element[], options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
39+
ScrollToFixed(el: {}, options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
40+
ScrollToFixed(el: JQuery, options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
41+
42+
scrollToFixed : (options? : ScrollToFixed.ScrollToFixedOptions) => JQuery[];
43+
}

0 commit comments

Comments
 (0)