Skip to content

Commit a750b9e

Browse files
committed
Add jQuery.scrollTo and related plugins
Fixes #8
1 parent 8fe4cf2 commit a750b9e

17 files changed

+1014
-0
lines changed
5.41 KB
Binary file not shown.
5.42 KB
Binary file not shown.
6.46 KB
Binary file not shown.

jquery.localScroll_1.3.5/CHANGES.htm

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<pre style="max-height: 20em; overflow: auto;">
2+
1.3.5
3+
[Fix]
4+
- Fixed when lazy true, links with 2+ levels of nested elements won't work, now using $().on()
5+
6+
1.3.4
7+
[Misc]
8+
- Turned into an unnamed AMD module and drop explicit requirement for jquery.scrollTo
9+
10+
1.3.3
11+
[Feature]
12+
- Added support for AMD
13+
14+
1.3.2
15+
[Fix]
16+
- Removed unneeded offset when hash setting is true
17+
[Misc]
18+
- Changed location to location.hash
19+
- Renamed component.json to bower.json and updated it
20+
21+
1.3.1
22+
[Misc]
23+
- Re-releasing for the jQuery plugins site
24+
25+
1.3.0
26+
[Misc]
27+
- Changed licensing to MIT
28+
- Repo is compliant with official jquery plugins repository
29+
30+
1.2.9
31+
[Fix]
32+
- hash:true incompatible with vertical offset
33+
[Enhancement]
34+
- $.localScroll.hash() is not needed anymore
35+
- Setting "reset" removed
36+
37+
1.2.8
38+
[Fix]
39+
- The setting 'stop' wasn't working on window.
40+
41+
1.2.7
42+
[Feature]
43+
- The set of settings can be accessed from within the onBefore as 'this'.
44+
- The hash is set before scrolling, so the back button works (when scrolling the window).
45+
- The option hash doesn't make the window jump when scrolling overflown elements (making it usable).
46+
- $.localScroll.hash now resets the element by default
47+
[Enhancement]
48+
- Various enhancements, updated to take advantage of scrollTo +1.4.x
49+
[Change]
50+
- The element that triggered the scroll cannot be accessed anymore (useless).
51+
- settings.persistent is no longer supported (was deprecated)
52+
53+
1.2.6
54+
[Enhancement]
55+
- areas(from image maps) are now formally supported, it was possible before by setting 'lazy' to true.
56+
[Fix]
57+
- When hash:true, a queue problem could arise.
58+
59+
1.2.5
60+
[Feature]
61+
- LocalScroll can now be safely combined with SerialScroll(1.2.0 or higher).
62+
63+
1.2.4
64+
[Feature]
65+
- If onBefore returns false, the event is ignored.
66+
- Relicensed from GPL to GPL+MIT.
67+
68+
1.2.3
69+
[Fix]
70+
- Added an extra check for an odd behavior of Firefox that it throws an error when checking the 'hash' attribute of a named anchor.
71+
72+
1.2.2
73+
[Optimizations]
74+
* Small improvements to make the code shorter.
75+
* Made the code to set the hash in the url, cleaner.
76+
[Features]
77+
* Added the option 'lock', if true, the plugin will ignore events if already animating.
78+
79+
1.2.1
80+
[Changes]
81+
* Renamed the option 'persistent' to 'lazy', I didn't like the name. Using persistent will still work (backwards compatibilty)
82+
83+
1.2
84+
[Optimizations]
85+
* Replaced a $('[name='+id+']') for a document.getElementsByName(id) to improve perfomance.
86+
[Fixes]
87+
* Now the last argument received by onBefore when scrolling the window, is no more $(window) but the real element being scrolled.
88+
[Features]
89+
* Added the option 'stop', if true (default), each click will stop any previous animations of the target.
90+
* Removed the option 'cancel' that wasn't working and added the option 'hash' that does that as it should. After the scroll, the hash is added to the address bar.
91+
* Added $.localScroll.hash( settings ); which will scroll to the given element if the URL contains a valid hash.
92+
[Changes]
93+
* Modified the regular demo, to make it show these last changes.
94+
95+
1.1.4
96+
* The event propagation is not stopped anymore, only the default prevented.
97+
* The option cancel works as expected (not yet)
98+
99+
1.1.3
100+
* Added semicolon to the start, for safe file concatenation
101+
* Changed the default named 'speed' for 'duration', following the change in jQuery.ScrollTo 1.3
102+
* jQuery.ScrollTo 1.3 improved the behavior when scrolling the window, among the different browsers, jQuery.localScroll now delegates this responsability completely.
103+
* Modified the demo according to these changes.
104+
* The third argument of onBefore, is now $(window) if settings.target is null (the whole window is scrolled)
105+
106+
1.1.2
107+
* The option 'persistent' has been added, if true, links can be added later, and will still work.
108+
* If 'cancel' is set to false, the default behaviour of the anchor will occur.
109+
* An event can be specified, if click is not the desired one.
110+
111+
1.1.1
112+
* The anchor filter has been optimized.
113+
* A bug was fixed, clicking an anchor with href=# and then a special link, wasn't scrolling.
114+
115+
1.1.0
116+
* The defaults have been made public.
117+
* Instead of letting jQuery.ScrollTo decide, the default speed has been overriden.
118+
</pre>

jquery.localScroll_1.3.5/LICENSE.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>jquery.localScroll is licened under the <a href="https://raw.githubusercontent.com/flesler/jquery.localScroll/1.3.5/LICENSE">MIT License</a>.</p>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<dotnetnuke type="Package" version="5.0">
2+
<packages>
3+
<package name="jquery.localScroll" type="JavaScript_Library" version="1.3.5">
4+
<friendlyName>jquery.localScroll</friendlyName>
5+
<description>This plugin will animate a regular anchor navigation. It will allow your visitors to navigate your site with a smooth scrolling effect. </description>
6+
<owner>
7+
<name>Engage Software</name>
8+
<organization>Engage Software</organization>
9+
<url>http://www.engagesoftware.com</url>
10+
<email>[email protected]</email>
11+
</owner>
12+
<license src="LICENSE.htm" />
13+
<releaseNotes src="CHANGES.htm" />
14+
<azureCompatible>true</azureCompatible>
15+
<dependencies>
16+
<dependency type="managedPackage" version="1.8.0">jQuery</dependency>
17+
<dependency type="managedPackage" version="1.4.11">jquery.scrollTo</dependency>
18+
</dependencies>
19+
<components>
20+
<component type="JavaScript_Library">
21+
<javaScriptLibrary>
22+
<libraryName>jquery.localScroll</libraryName>
23+
<fileName>jquery.localScroll.js</fileName>
24+
<preferredScriptLocation>BodyBottom</preferredScriptLocation>
25+
<CDNPath>https://cdnjs.cloudflare.com/ajax/libs/jquery-localScroll/1.3.5/jquery.localScroll.min.js</CDNPath>
26+
<objectName>jQuery.localScroll</objectName>
27+
</javaScriptLibrary>
28+
</component>
29+
<component type="JavaScriptFile">
30+
<jsfiles>
31+
<libraryFolderName>jquery.localScroll</libraryFolderName>
32+
<jsfile>
33+
<name>jquery.localScroll.js</name>
34+
</jsfile>
35+
</jsfiles>
36+
</component>
37+
</components>
38+
</package>
39+
</packages>
40+
</dotnetnuke>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*!
2+
* jQuery.localScroll
3+
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
4+
* Licensed under MIT
5+
* http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html
6+
* @author Ariel Flesler
7+
* @version 1.3.5
8+
*/
9+
;(function(plugin) {
10+
// AMD Support
11+
if (typeof define === 'function' && define.amd) {
12+
define(['jquery'], plugin);
13+
} else {
14+
plugin(jQuery);
15+
}
16+
}(function($) {
17+
var URI = location.href.replace(/#.*/, ''); // local url without hash
18+
19+
var $localScroll = $.localScroll = function(settings) {
20+
$('body').localScroll(settings);
21+
};
22+
23+
// Many of these defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option.
24+
// @see http://demos.flesler.com/jquery/scrollTo/
25+
// The defaults are public and can be overriden.
26+
$localScroll.defaults = {
27+
duration: 1000, // How long to animate.
28+
axis: 'y', // Which of top and left should be modified.
29+
event: 'click', // On which event to react.
30+
stop: true, // Avoid queuing animations
31+
target: window // What to scroll (selector or element). The whole window by default.
32+
/*
33+
lock: false, // ignore events if already animating
34+
lazy: false, // if true, links can be added later, and will still work.
35+
filter: null, // filter some anchors out of the matched elements.
36+
hash: false // if true, the hash of the selected link, will appear on the address bar.
37+
*/
38+
};
39+
40+
$.fn.localScroll = function(settings) {
41+
settings = $.extend({}, $localScroll.defaults, settings);
42+
43+
if (settings.hash && location.hash) {
44+
if (settings.target) window.scrollTo(0, 0);
45+
scroll(0, location, settings);
46+
}
47+
48+
return settings.lazy ?
49+
// use event delegation, more links can be added later.
50+
this.on(settings.event, 'a,area', function(e) {
51+
if (filter.call(this)) {
52+
scroll(e, this, settings);
53+
}
54+
}) :
55+
// bind concretely, to each matching link
56+
this.find('a,area')
57+
.filter(filter).bind(settings.event, function(e) {
58+
scroll(e, this, settings);
59+
}).end()
60+
.end();
61+
62+
function filter() {// is this a link that points to an anchor and passes a possible filter ? href is checked to avoid a bug in FF.
63+
return !!this.href && !!this.hash && this.href.replace(this.hash,'') == URI && (!settings.filter || $(this).is(settings.filter));
64+
};
65+
};
66+
67+
// Not needed anymore, kept for backwards compatibility
68+
$localScroll.hash = function() {};
69+
70+
function scroll(e, link, settings) {
71+
var id = link.hash.slice(1),
72+
elem = document.getElementById(id) || document.getElementsByName(id)[0];
73+
74+
if (!elem)
75+
return;
76+
77+
if (e)
78+
e.preventDefault();
79+
80+
var $target = $(settings.target);
81+
82+
if (settings.lock && $target.is(':animated') ||
83+
settings.onBefore && settings.onBefore(e, elem, $target) === false)
84+
return;
85+
86+
if (settings.stop)
87+
$target._scrollable().stop(true); // remove all its animations
88+
89+
if (settings.hash) {
90+
var attr = elem.id === id ? 'id' : 'name',
91+
$a = $('<a> </a>').attr(attr, id).css({
92+
position:'absolute',
93+
top: $(window).scrollTop(),
94+
left: $(window).scrollLeft()
95+
});
96+
97+
elem[attr] = '';
98+
$('body').prepend($a);
99+
location.hash = link.hash;
100+
$a.remove();
101+
elem[attr] = id;
102+
}
103+
104+
$target
105+
.scrollTo(elem, settings) // do scroll
106+
.trigger('notify.serialScroll',[elem]); // notify serialScroll about this change
107+
};
108+
109+
// AMD requirement
110+
return $localScroll;
111+
112+
}));

jquery.localScroll_1.3.5/jquery.localScroll.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)