Issue 2085: Selection bug when slotDuration and snapDuration have different values
Status:  Released
Owner: ----
Closed:  Jun 2014
Feb 25, 2014
#1 jnanney@gmail.com
I'm having a similar issue when dragging external events to the calendar. The differing snapDuration and slotDuration are normalized when the coordinateGrid is created, but the realCellToDate function does not take into account the snapRatio.

I've narrowed it down to this and will report back my findings on what I did to fix it and whether that fix affects any other code in the project.



The coordinate grid is created with the rows normalized for the snapRatio in AgendaView.js line 687:

		for (var i=0; i<slotCnt*snapRatio; i++) { // adapt slot count to increased/decreased selection slot count
			rows.push([
				constrain(slotTableTop + snapHeight*i),
				constrain(slotTableTop + snapHeight*(i+1))
			]);
		}


Then in the AgendaView.js on line 741 in the RealCellToDate function, the time is computed without taking into account the snapRatio.

	function realCellToDate(cell) { // ugh "real" ... but blame it on our abuse of the "cell" system

		var date = cellToDate(0, cell.col);

		var slotIndex = cell.row;

		if (opt('allDaySlot')) {
			slotIndex--;
		}

		if (slotIndex >= 0) {
			date.time(moment.duration(minTime + slotIndex * slotDuration));
			date = calendar.rezoneDate(date);
		}
		return date;
	}


Feb 25, 2014
#2 jnanney@gmail.com
Changing the realCellToDate function to include dividing by the ratio, fixes the external drag problem. I'm wondering if it will fix the selection problem or if there is somewhere else this calculation is made (and thus needs to be another function.

Here's the code fix to realCellToDate(cell)

		if (slotIndex >= 0) {
			var divisor = (slotIndex === 0) ? 1 : snapRatio;
			date.time(moment.duration(minTime + (slotIndex / divisor)  * slotDuration));
			date = calendar.rezoneDate(date);
		}


I will continue to look for other areas where this duration calculated and report back.
Feb 25, 2014
#3 NBst...@gmail.com
http://jsfiddle.net/nbstrat/VR387/13/

Contains the jnanny fix at line 4217
Feb 27, 2014
#4 NBst...@gmail.com
Added the select conditions to the fiddle to duplicate the condition described in the original bug ticket. Looks likes Jim's fix corrected that problem also.

http://jsfiddle.net/nbstrat/VR387/18/
Mar 21, 2014
Project Member #5 adamrs...@gmail.com
(No comment was entered for this change.)
Summary: Selection bug when slotDuration and snapDuration have different values (was: [v2] Selection bug when slotDuration and snapDuration have different values)
Status: Reproducing
Labels: Type-Bug milestone-date
Mar 21, 2014
#6 jnanney@gmail.com
I was unable to create a test with jasmine because I don't yet know how to mock the drag and mouseover events. Also had one failing test from checkout of v2 branch.

If you'd like more details I am happy to provide what I can.
May 25, 2014
Project Member #7 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Implemented
May 25, 2014
Project Member #8 adamrs...@gmail.com
 Issue 2142  has been merged into this issue.
May 25, 2014
Project Member #9 adamrs...@gmail.com
 Issue 2141  has been merged into this issue.
Jun 2, 2014
Project Member #10 adamrs...@gmail.com
version 2 has been released with this change.
http://blog.arshaw.com/1/post/2014/06/fullcalendar-2-released.html
Status: Released