Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Error out in .update if the markup requirements aren't met

  • Loading branch information...
commit 8e68545f4ce97e95d3022c35cf9201ec2a7df44a 1 parent ee4dc7b
@Empact Empact authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 jquery.tinyscrollbar.js
View
15 jquery.tinyscrollbar.js
@@ -48,16 +48,21 @@
this.active = function() {
return self.contentRatio < 1;
}
+ function requirements_met() {
+ return (viewport.length && content.length && scrollbar.length && track.length && thumb.length)
+ }
+
function initialize() {
- if (!(viewport.length && content.length && scrollbar.length && track.length && thumb.length)) {
- return null;
+ if (requirements_met()) {
+ self.update();
+ setEvents();
}
-
- self.update();
- setEvents();
return self;
}
this.update = function(sScroll){
+ if (!requirements_met()) {
+ $.error("Missing required tinyscrollbar sub-element: either .viewport .overview .scrollbar .track or .thumb");
+ }
var viewportSize = viewport[0]['offset'+ sSize];
var contentSize = content[0]['scroll'+ sSize];
offscreenSize = contentSize - viewportSize;
Please sign in to comment.
Something went wrong with that request. Please try again.