Showing posts with label jQuery.ScrollTo. Show all posts
Showing posts with label jQuery.ScrollTo. Show all posts

Monday, May 25, 2009

jQuery.ScrollTo 1.4.2 released

Notice

I've pretty much stopped updating this blog, but the plugin development is still on-going. You can find the link to the Github project page at the bottom of the article.

Fixes

  • Fixing max calculations for regular DOM elements.

Features

  • The plugin support percentages as target ('50%' or {top:'50%', left:'45%'}).
  • Exposed the max() calculation as $.scrollTo.max.

Enhancements

  • Renamed $.fn.scrollable to $.fn._scrollable to avoid conflicts with other plugins.

Links

Monday, March 9, 2009

jQuery.ScrollTo 1.4.1 released

Fixes

  • The plugin accepts floating numbers.
  • Using jQuery.nodeName where neccessary so that this works on xml+xhtml.
  • The max() internal function wasn't completely accurrate, now it is 98% (except for IE on quirks mode but it's not too noticeable).

Features

  • The target can be 'max' to scroll to the end while keeping it elegant.
  • The plugin works on quirks mode.

Enhancements

  • Default duration is 0 for jquery +1.3. Means sync animations.
  • Rewrote $.fn.scrollable() again. The plugin works on all major browsers (FF, IE, Safari, Opera, Chrome), on all versions, compat & quirks modes, even for iframes.
  • In addition to window/document, if html or body are received, the plugin will choose the right one.

Links

Thursday, September 11, 2008

jQuery.ScrollTo 1.4 released!

Fixes

  • Fixed the problem when scrolling the window to absolute positioned elements on Safari.
  • Fixed the problem on Opera 9.5 when scrolling the window. That it always scrolls to 0.

Features

  • Added the settings object as 2nd argument to the onAfter callback.
  • The 3rd argument of scrollTo can be just a function and it's used as the onAfter.
  • Added full support for iframes (even max scroll calculation).
  • Instead of $.scrollTo, $(window).scrollTo() and $(document).scrollTo() can be used(even for iframes).
  • Added $().scrollable() that returns the real element to scroll, f.e: $(window).scrollable() == [body|html], works for iframes too.

I rewrote the scroll limit calculations part, in order to fix the 2 bugs. If you notice any problem, please report.

This version should be perfectly compatible with the latest versions of SerialScroll and LocalScroll.

I tested this only with jQuery 1.2.6 (from trunk) but it should work well even with pretty old versions of jQuery.

Tested my demos and some iframe experiments on IE 6/7, FF 2/3, Safari 3 and Opera 9.2/5. All worked as expected. Enjoy!

Links

Monday, October 29, 2007

jQuery.ScrollTo 1.2 released

Changes

  • The option 'onafter' is now called 'onAfter'.
  • The option 'margin' can be setted to true, then the margin of the target element, will be taken into account and will be deducted.
  • Two axis can be scrolled together, this is setted with the option 'axis'.
  • In case 2 axis are chosen, the scrolling can be queued: one scrolls, and then the other.
  • There's an intermediary event, 'onAfterFirst' called in case the axis are queued, after the first ends.
  • If the option 'margin' is set to true, the plugin will take in account, the margin of the target(no use if target is a value).

Notes

  • If queuing is activated, the order of the axes ('xy' or 'yx') will tell the plugin, in what order to scroll the axis.
  • 'margin' will only be valid, if the target is a selector, a DOM element, or a jQuery Object.
  • If the first axis to be scrolled, is already positioned, that animation will be skipped, to avoid a delay in the animation.
Along with this release, jQuery.LocalScroll 1.0.1 is released. Changes:
  • 'onbefore' is now named 'onBefore', to keep jQuery.ScrollTo naming conventions.
  • A filter can be specified, so that only some of the suitable links are bound.

Links

Wednesday, October 24, 2007

jQuery.ScrollTo 1.1 released

Changes

  • Relative animations are now supported.
  • Fixed a bug, the plugin would fail if the 'target' is a selector and it ends with a number.
  • The 'target' selector no longer supports 'em' or '%' as they won't work with animate anyway.
  • The plugin is no longer dependant on jQuery.Dimensions! :)
  • Fixed a bug, any-number + 'px' or relative animations, combined with no speed or speed 0 would fail. This no longer happens.

Links

Thursday, October 18, 2007

jQuery.ScrollTo

Notice

I've pretty much stopped updating this blog, but the plugin development is still on-going. You can find the link to the Github project page at the bottom of the article.

Introduction

An article about animated scrolling with jQuery inspired me to make a small, customizable plugin for scrolling elements, or the window itself.

How to specify what to scroll ?

Simple, all the matched elements will be scrolled, for example:
$('div.pane').scrollTo(...);//all divs w/class pane
If you need to scroll the window (screen), then use:
$.scrollTo(...);//the plugin will take care of this

How to specify where ?

There are many different ways to specify the target position.
These are:
  • A raw number
  • A string('44', '100px', '+=30px', etc )
  • A DOM element (logically, child of the scrollable element)
  • A selector, that will be relative to the scrollable element
  • The string 'max' to scroll to the end.
  • A string specifying a percentage to scroll to that part of the container (f.e: 50% goes to to the middle).
  • A hash { top:x, left:y }, x and y can be any kind of number/string like above.
Note that you only need to use the hash form, if you are scrolling on both axes, and they have different positions.
Don't use the hash to scroll on both axes. Instead, keep reading :)

Settings

The plugin offers you many options to customize the animation and also the final position.
The settings are:
  • axis: Axes to be scrolled, 'x', 'y', 'xy' or 'yx'. 'xy' is the default.
  • duration: Length of the animation, none (sync) by default.
  • easing: Name of the easing equation.
  • margin: If true, target's border and margin are deducted.
  • offset: Number or hash {left: x, top:y }. This will be added to the final position(can be negative).
  • over: Add a fraction of the element's height/width (can also be negative).
  • queue: If true and both axes are scrolled, it will animate on one axis, and then on the other. Note that 'axis' being 'xy' or 'yx', concludes the order
  • onAfterFirst: If queing, a function to be called after scrolling the first axis.
  • onAfter: A function to be called after the whole animation ended.
  • You can use any other setting accepted by $().animate()
These settings are very well explained in the demo. Make sure to check it to understand them all.

Manually finding the scrolling limit

$.scrollTo always had an internal function that calculates the scrolling limit for both axes. Since 1.4.2, this function is exposed as $.scrollTo.max.

It's not too nice to use yet but it's probably not something you'll need, you must pass two arguments: a DOM element and an axis string ('x' or 'y') and it will return the max number.


Overloading

This plugin accepts the arguments in two ways, like $.animate().
$(...).scrollTo( target, duration, settings );
$(...).scrollTo( target, settings );
In this second case, you can specify the duration in the hash. You don't need to include any setting, not even the duration, everything has defaults.
The hash of defaults can be accessed at: $.scrollTo.defaults.

jQuery.scrollTo's sons

Indeed, jQuery.scrollTo has offspring :)
  • jQuery.localScroll: Will add a scroll effect, to any anchor navigation. Ideal for slides, table of contents, etc. It's small, and incredibly easy to implement.
  • jQuery.serialScroll: It's a multi-purpose plugin to animate any kind of sequential navigation(prev/next). It's also small and highly customizable.
These plugins require jQuery.scrollTo and can use its settings!.
That makes around 20 options to fully customize each of them.
They are wrappers for common situations where you might need this plugin.
Using them will save you a lot of time and will give you even more customization.
They can be safely used simultaneously and the 3 of them minified, take merely 3.5kb altogether!

Troubleshooting

Doesn't scroll on IE
Sometimes, you need to set a position (relative or absolute) to the container and give it fixed dimensions, in order to hide the overflow.
If this doesn't work, try giving the container fixed dimensions (height & width).

Links