Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix(weekView): account for scrollbars when doing the drag select on t…

…he week view with times

Closes #571
  • Loading branch information...
Matt Lewis
Matt Lewis committed Apr 17, 2017
1 parent fe064d2 commit 0e56ac9f5daef43a87e7816f9c70aad31ee421e0
Showing with 30 additions and 2 deletions.
  1. +29 −1 src/directives/mwlCalendarHourList.js
  2. +1 −1 src/templates/calendarHourList.html
@@ -5,9 +5,37 @@ var calendarUtils = require('calendar-utils');

angular
.module('mwl.calendar')
.controller('MwlCalendarHourListCtrl', function($scope, moment, calendarHelper) {
.controller('MwlCalendarHourListCtrl', function($scope, $document, moment, calendarHelper) {
var vm = this;

// source: http://stackoverflow.com/questions/13382516/getting-scroll-bar-width-using-javascript
function getScrollbarWidth() {
var outer = $document[0].createElement('div');
outer.style.visibility = 'hidden';
outer.style.width = '100px';
outer.style.msOverflowStyle = 'scrollbar'; // needed for WinJS apps

$document[0].body.appendChild(outer);

var widthNoScroll = outer.offsetWidth;
// force scrollbars
outer.style.overflow = 'scroll';

// add innerdiv
var inner = $document[0].createElement('div');
inner.style.width = '100%';
outer.appendChild(inner);

var widthWithScroll = inner.offsetWidth;

// remove divs
outer.parentNode.removeChild(outer);

return widthNoScroll - widthWithScroll;
}

vm.scrollBarWidth = getScrollbarWidth();

function updateDays() {

vm.dayViewSplit = parseInt(vm.dayViewSplit);
@@ -32,7 +32,7 @@
<div
class="cal-day-hour-part-spacer"
ng-repeat="day in segment.days track by $index"
ng-style="{width: vm.dayWidth + 'px'}"
ng-style="{width: (vm.dayWidth - ($last ? vm.scrollBarWidth : 0)) + 'px'}"
ng-class="[{ 'cal-day-hour-part-selected': vm.dateRangeSelect &&
vm.dateRangeSelect.startDate <= day.date &&
day.date < vm.dateRangeSelect.endDate }, day.cssClass]"

0 comments on commit 0e56ac9

Please sign in to comment.
You can’t perform that action at this time.