Add new definition and tests for jQuery.scrollTo

This commit is contained in:
Neil Stalker 2013-02-26 19:27:30 +00:00
parent 2bc4510511
commit 2263f217f9
3 changed files with 148 additions and 0 deletions

View File

@ -81,6 +81,7 @@ List of Definitions
* [jQuery.form](http://malsup.com/jquery/form/) (by [Fran<EFBFBD>ois Guillot](http://fguillot.developpez.com/))
* [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov))
* [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/))
* [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/))
* [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/))
* [jQuery.timeago](http://timeago.yarp.com/) (by [Fran<EFBFBD>ois Guillot](http://fguillot.developpez.com/))
* [jQuery.Timepicker](http://fgelinas.com/code/timepicker/) (by [Anwar Javed](https://github.com/anwarjaved))

View File

@ -0,0 +1,31 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="jquery.scrollTo.d.ts"/>
$('div').scrollTo(340);
$('div').scrollTo('+=340px', { axis: 'y' });
$('div').scrollTo('p.paragraph:eq(2)', 500, { easing: 'swing', queue: true, axis: 'xy' });
var second_child = document.getElementById('container').firstChild.nextSibling;
$('#container').scrollTo(second_child, {
duration: 500, axis: 'x', onAfter: function () {
alert('scrolled!!');
}
});
$('div').scrollTo({ top: 300, left: '+=200' }, { axis: 'xy', offset: -20 });
$.scrollTo(340);
$.scrollTo('+=340px', { axis: 'y' });
$.scrollTo('p.paragraph:eq(2)', 500, { easing: 'swing', queue: true, axis: 'xy' });
$.scrollTo(second_child, {
duration: 500, axis: 'x', onAfter: function () {
alert('scrolled!!');
}
});
$.scrollTo({ top: 300, left: '+=200' }, { axis: 'xy', offset: -20 });

116
jquery.scrollTo/jquery.scrollTo.d.ts vendored Normal file
View File

@ -0,0 +1,116 @@
// Type definitions for jQuery.scrollTo.js 1.4.4
// Project: https://github.com/flesler/jquery.scrollTo
// Definitions by: Neil Stalker <https://github.com/nestalk>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
interface ScrollToOptions {
/**
* Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
*/
axis?: string;
/**
* The OVERALL length of the animation.
*/
duration?: any;
/**
* The easing method for the animation.
*/
easing?: string;
/**
* If true, the margin of the target element will be deducted from the final position.
*/
margin?: bool;
/**
* Add/deduct from the end position.
* One number for both axes or { top:x, left:y }.
*/
offset?: any;
/**
* Add/deduct the height/width multiplied by 'over'.
* Can be { top:x, left:y } when using both axes.
*/
over? : any;
/**
* If true, and both axis are given.
* The 2nd axis will only be animated after the first one ends.
*/
queue?: bool;
/**
* Function to be called after the scrolling ends.
*/
onAfter?: () => void;
/**
* If queuing is activated, this function will be called after the first scrolling ends.
*/
onAfterFirst?: () => void;
}
interface JQuery {
/**
* Scroll the matched elements
*/
scrollTo: {
/**
* Scroll the matched elements
*
* @param target Where to scroll the matched elements.
* @param duration The OVERALL length of the animation
* @param settings Set of settings.
*/
(target: any, duration?: number, settings?: ScrollToOptions): JQuery;
/**
* Scroll the matched elements
*
* @param target Where to scroll the matched elements.
* @param duration The OVERALL length of the animation
* @param onAfter The onAfter callback.
*/
(target: any, duration: number, onAfter?: Function): JQuery;
/**
* Scroll the matched elements
*
* @param target Where to scroll the matched elements.
* @param settings Set of settings.
* @param onAfter The onAfter callback.
*/
(target: any, settings: ScrollToOptions, onAfter?: Function): JQuery;
};
}
interface JQueryStatic {
/**
* Scroll window
*/
scrollTo: {
/**
* Scroll window
*
* @param target Where to scroll the matched elements.
* @param duration The OVERALL length of the animation
* @param settings Set of settings.
*/
(target: any, duration?: number, settings?: ScrollToOptions): JQuery;
/**
* Scroll window
*
* @param target Where to scroll the matched elements.
* @param duration The OVERALL length of the animation
* @param onAfter The onAfter callback.
*/
(target: any, duration: number, onAfter?: Function): JQuery;
/**
* Scroll window
*
* @param target Where to scroll the matched elements.
* @param settings Set of settings.
* @param onAfter The onAfter callback.
*/
(target: any, settings: ScrollToOptions, onAfter?: Function): JQuery;
};
}