Permalink
Browse files

- added a refresh method to the api

- updated demo to reflect changes
- updated jquery to 1.7 because of this bug http://stackoverflow.com/questions/7825448/webkit-issues-with-event-layerx-and-event-layery
  • Loading branch information...
1 parent fa1eb21 commit a1b14024b016b246624c8d451dacd2b1bf8b6148 @pgherveou pgherveou committed Jan 7, 2012
Showing with 1,662 additions and 1,337 deletions.
  1. +22 −3 antiscroll.js
  2. +1,581 −1,327 deps/jquery.js
  3. +59 −7 index.html
View
@@ -39,14 +39,33 @@
, 'height': '+=' + scrollbarSize()
});
- if (this.inner.get(0).scrollWidth > this.el.width()) {
+ this.refresh();
+ };
+
+ /**
+ * refresh scrollbars
+ *
+ * @api public
+ */
+ Antiscroll.prototype.refresh = function() {
+ var needHScroll = this.inner.get(0).scrollWidth > this.el.width()
+ , needVScroll = this.inner.get(0).scrollHeight > this.el.height();
+
+ if (!this.horizontal && needHScroll) {
this.horizontal = new Scrollbar.Horizontal(this);
+ } else if (this.horizontal && !needHScroll) {
+ this.horizontal.destroy();
+ this.horizontal = null
}
- if (this.inner.get(0).scrollHeight > this.el.height()) {
+ if (!this.vertical && needVScroll) {
this.vertical = new Scrollbar.Vertical(this);
+ } else if (this.vertical && !needVScroll) {
+ this.vertical.destroy();
+ this.vertical = null
}
- }
+
+ };
/**
* Cleans up.
Oops, something went wrong.

0 comments on commit a1b1402

Please sign in to comment.