thekingsimo / jquery-week-calendar

Automatically exported from code.google.com/p/jquery-week-calendar
0 stars 0 forks source link

_scrollToHour is not working if display is limited to businessHours #94

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

If display is limited to businessHours, the scrolling does not work. Can be
fixed by changin the _scrollToHour function from (SVN rev 67):

      _scrollToHour : function(hour) {
         var self = this;
         var options = this.options;
         var $scrollable = this.element.find(".wc-scrollable-grid");
         var slot = hour;
         if (self.options.businessHours.limitDisplay) {
            if (hour < self.options.businessHours.start) {
               slot = 0;
            } else if (hour > self.options.businessHours.end) {
               slot = self.options.businessHours.end -
self.options.businessHours.start - 1;
            }
         }

         var $target = this.element.find(".wc-grid-timeslot-header
.wc-hour-header:eq(" + slot + ")");

         $scrollable.animate({scrollTop: 0}, 0, function() {
            var targetOffset = $target.offset().top;
            var scroll = targetOffset - $scrollable.offset().top -
$target.outerHeight();
            $scrollable.animate({scrollTop: scroll},
options.scrollToHourMillis);
         });
      }

to:

      _scrollToHour : function(hour) {
         var self = this;
         var options = this.options;
         var $scrollable = this.element.find(".wc-scrollable-grid");
         var slot = hour;
         if (self.options.businessHours.limitDisplay) {
            if (hour <= self.options.businessHours.start) {
               slot = 0;
            } else if (hour > self.options.businessHours.end) {
               slot = self.options.businessHours.end -
self.options.businessHours.start - 1;
            } else {
               slot = hour - self.options.businessHours.start;
            }
         }

         var $target = this.element.find(".wc-grid-timeslot-header
.wc-hour-header:eq(" + slot + ")");

         $scrollable.animate({scrollTop: 0}, 0, function() {
            var targetOffset = $target.offset().top;
            var scroll = targetOffset - $scrollable.offset().top -
$target.outerHeight();
            $scrollable.animate({scrollTop: scroll},
options.scrollToHourMillis);
         });
      }

I tested it only with 24 hour times and seems to work ok.

Original issue reported on code.google.com by doze...@gmail.com on 19 Oct 2009 at 10:07

GoogleCodeExporter commented 8 years ago
nice find, thanks!

Original comment by robmo...@gmail.com on 30 Oct 2009 at 5:47