diff --git a/README.md b/README.md index 20f7a0a5e4..ce1f5138c9 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ List of Definitions * [jQuery.form](http://malsup.com/jquery/form/) (by [Fran�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�ois Guillot](http://fguillot.developpez.com/)) * [jQuery.Timepicker](http://fgelinas.com/code/timepicker/) (by [Anwar Javed](https://github.com/anwarjaved)) diff --git a/jquery.scrollTo/jquery.scrollTo-tests.ts b/jquery.scrollTo/jquery.scrollTo-tests.ts new file mode 100644 index 0000000000..009112606f --- /dev/null +++ b/jquery.scrollTo/jquery.scrollTo-tests.ts @@ -0,0 +1,31 @@ +/// +/// + +$('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 }); \ No newline at end of file diff --git a/jquery.scrollTo/jquery.scrollTo.d.ts b/jquery.scrollTo/jquery.scrollTo.d.ts new file mode 100644 index 0000000000..93e231e50f --- /dev/null +++ b/jquery.scrollTo/jquery.scrollTo.d.ts @@ -0,0 +1,116 @@ +// Type definitions for jQuery.scrollTo.js 1.4.4 +// Project: https://github.com/flesler/jquery.scrollTo +// Definitions by: Neil Stalker +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +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; + + }; + +}