if handler functions are null, don't do anything.
This commit is contained in:
Hyunje Alex Jun
2012-11-10 13:41:31 +09:00
parent 8a7a471522
commit db020f1d29
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -4,17 +4,21 @@
((function($) {
$.fn.perfectScrollbar = function(option) {
if(option === 'update') {
$(this).data('perfect_scrollbar_update')();
return;
if($(this).data('perfect_scrollbar_update')) {
$(this).data('perfect_scrollbar_update')();
}
return $(this);
}
else if(option === 'destroy') {
$(this).data('perfect_scrollbar_destroy')();
return;
if($(this).data('perfect_scrollbar_destroy')) {
$(this).data('perfect_scrollbar_destroy')();
}
return $(this);
}
if($(this).data('perfect_scrollbar')) {
// if there's already perfect_scrollbar
return;
return $(this).data('perfect_scrollbar');
}
var $this = $(this).addClass('ps-container'),
@@ -189,7 +193,7 @@
bindMouseScrollXHandler();
bindMouseScrollYHandler();
if($this.mousewheel) bindMouseWheelHandler();
$this.data('perfect_scrollbar', true);
$this.data('perfect_scrollbar', $this);
$this.data('perfect_scrollbar_update', updateBarSizeAndPosition);
$this.data('perfect_scrollbar_destroy', destroy);
};