Skip to content

Commit ed12672

Browse files
committed
Merge pull request DefinitelyTyped#4671 from EnableSoftware/Add-ScrollToFixed
Add definitions for ScrollToFixed
2 parents aab41f1 + 55e4441 commit ed12672

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

scrolltofixed/scrolltofixed-tests.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
$('#summary').scrollToFixed({
21+
marginTop: $('.header').outerHeight() + 10,
22+
limit: function() {
23+
var limit = $('.footer').offset().top - $('#summary').outerHeight(true) - 10;
24+
return limit;
25+
},
26+
zIndex: 999,
27+
preFixed: function() { $(this).find('.title').css('color', 'blue'); },
28+
preAbsolute: function() { $(this).find('.title').css('color', 'red'); },
29+
postFixed: function() { $(this).find('.title').css('color', ''); },
30+
postAbsolute: function() { $(this).find('.title').css('color', ''); }
31+
});
32+
});
33+
34+
var b = $.isScrollToFixed('.header');

scrolltofixed/scrolltofixed.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
postFixed?: () => void;
17+
fixed?: () => void;
18+
unfixed?: () => void;
19+
preUnfixed?: () => 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+
baseClassName?: string;
30+
className?: string;
31+
}
32+
}
33+
34+
interface JQuery {
35+
scrollToFixed : (options? : ScrollToFixed.ScrollToFixedOptions) => JQuery[];
36+
}
37+
38+
interface JQueryStatic {
39+
isScrollToFixed(el: Element) : JQuery;
40+
isScrollToFixed(el: Element[]) : JQuery;
41+
isScrollToFixed(el: {}) : JQuery;
42+
isScrollToFixed(el: JQuery) : JQuery;
43+
44+
ScrollToFixed(el: Element, options: ScrollToFixed.ScrollToFixedOptions): void;
45+
ScrollToFixed(el : Element, options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
46+
ScrollToFixed(el: Element[], options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
47+
ScrollToFixed(el: {}, options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
48+
ScrollToFixed(el: JQuery, options : ScrollToFixed.ScrollToFixedOptions) : JQuery;
49+
}

0 commit comments

Comments
 (0)