diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/jquery.doubleScroll.js b/jquery.doubleScroll.js
index 139c4ff..23b4605 100644
--- a/jquery.doubleScroll.js
+++ b/jquery.doubleScroll.js
@@ -10,28 +10,36 @@
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
-
-(function($){
+
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['jquery'], factory);
+ } else {
+ // Browser globals
+ factory(jQuery);
+ }
+}(function ($) {
$.widget("suwala.doubleScroll", {
- options: {
+ options: {
contentElement: undefined, // Widest element, if not specified first child element will be used
- topScrollBarMarkup: '
',
- topScrollBarInnerSelector: '.suwala-doubleScroll-scroll',
- scrollCss: {
- 'overflow-x': 'scroll',
- 'overflow-y':'hidden'
+ topScrollBarMarkup: '',
+ topScrollBarInnerSelector: '.suwala-doubleScroll-scroll',
+ scrollCss: {
+ 'overflow-x': 'scroll',
+ 'overflow-y': 'hidden'
},
- contentCss: {
- 'overflow-x': 'scroll',
- 'overflow-y':'hidden'
- }
- },
- _create : function() {
+ contentCss: {
+ 'overflow-x': 'scroll',
+ 'overflow-y': 'hidden'
+ }
+ },
+ _create: function () {
var self = this;
- var contentElement;
+ var contentElement;
// add div that will act as an upper scroll
- var topScrollBar = $($(self.options.topScrollBarMarkup));
+ var topScrollBar = $($(self.options.topScrollBarMarkup));
self.element.before(topScrollBar);
// find the content element (should be the widest one)
@@ -43,12 +51,12 @@
}
// bind upper scroll to bottom scroll
- topScrollBar.scroll(function(){
+ topScrollBar.scroll(function () {
self.element.scrollLeft(topScrollBar.scrollLeft());
});
-
+
// bind bottom scroll to upper scroll
- self.element.scroll(function(){
+ self.element.scroll(function () {
topScrollBar.scrollLeft(self.element.scrollLeft());
});
@@ -60,11 +68,11 @@
$(self.options.topScrollBarInnerSelector, topScrollBar).width(contentElement[0].scrollWidth);
topScrollBar.width(self.element[0].clientWidth);
},
- refresh: function(){
+ refresh: function () {
// this should be called if the content of the inner element changed.
// i.e. After AJAX data load
var self = this;
- var contentElement;
+ var contentElement;
var topScrollBar = self.element.parent().find('.suwala-doubleScroll-scroll-wrapper');
// find the content element (should be the widest one)
@@ -80,4 +88,4 @@
topScrollBar.width(self.element[0].clientWidth);
}
});
-})(jQuery);
+}));