@@ -64,7 +64,7 @@ export function iterateTimes(start, end, unit, timeSteps, callback) {
6464
6565 if ( timeSteps [ unit ] && timeSteps [ unit ] > 1 ) {
6666 let value = time . get ( unit )
67- time . set ( unit , value - value % timeSteps [ unit ] )
67+ time . set ( unit , value - ( value % timeSteps [ unit ] ) )
6868 }
6969
7070 while ( time . valueOf ( ) < end ) {
@@ -258,7 +258,7 @@ export function stack(items, groupOrders, lineHeight, groups) {
258258 var groupedItems = getGroupedItems ( items , groupOrders )
259259
260260 groupedItems . forEach ( function ( group ) {
261- var groupVal = groups [ k ++ ] ;
261+ var groupVal = groups [ k ++ ]
262262
263263 // calculate new, non-overlapping positions
264264 groupTops . push ( totalHeight )
@@ -317,7 +317,9 @@ export function stack(items, groupOrders, lineHeight, groups) {
317317}
318318
319319export function nostack ( items , groupOrders , lineHeight , groups ) {
320- var i , j = 0 , iMax
320+ var i ,
321+ j = 0 ,
322+ iMax
321323
322324 var totalHeight = 0
323325
@@ -327,7 +329,7 @@ export function nostack(items, groupOrders, lineHeight, groups) {
327329 var groupedItems = getGroupedItems ( items , groupOrders )
328330
329331 groupedItems . forEach ( function ( group ) {
330- var groupVal = groups [ j ++ ] ;
332+ var groupVal = groups [ j ++ ]
331333
332334 // calculate new, non-overlapping positions
333335 groupTops . push ( totalHeight )
@@ -344,8 +346,8 @@ export function nostack(items, groupOrders, lineHeight, groups) {
344346 }
345347
346348 if ( groupVal . height ) {
347- groupHeights . push ( groupVal . height ) ;
348- totalHeight += groupVal . height ;
349+ groupHeights . push ( groupVal . height )
350+ totalHeight += groupVal . height
349351 } else {
350352 groupHeights . push ( Math . max ( groupHeight , lineHeight ) )
351353 totalHeight += Math . max ( groupHeight , lineHeight )
@@ -361,24 +363,24 @@ export function nostack(items, groupOrders, lineHeight, groups) {
361363/**
362364 * Stack the items that will be visible
363365 * within the canvas area
364- * @param {item[] } items
365- * @param {group[] } groups
366- * @param {number } canvasTimeStart
367- * @param {number } visibleTimeStart
368- * @param {number } visibleTimeEnd
369- * @param {number } width
370- * @param {* } props
371- * @param {* } state
366+ * @param {item[] } items
367+ * @param {group[] } groups
368+ * @param {number } canvasTimeStart
369+ * @param {number } visibleTimeStart
370+ * @param {number } visibleTimeEnd
371+ * @param {number } width
372+ * @param {* } props
373+ * @param {* } state
372374 */
373375export function stackItems (
374- items ,
375- groups ,
376- canvasTimeStart ,
377- visibleTimeStart ,
378- visibleTimeEnd ,
379- width ,
380- props ,
381- state
376+ items ,
377+ groups ,
378+ canvasTimeStart ,
379+ visibleTimeStart ,
380+ visibleTimeEnd ,
381+ width ,
382+ props ,
383+ state
382384) {
383385 // if there are no groups return an empty array of dimensions
384386 if ( groups . length === 0 ) {
@@ -416,13 +418,11 @@ state
416418 // Get the order of groups based on their id key
417419 const groupOrders = getGroupOrders ( groups , keys )
418420
419-
420421 let dimensionItems = visibleItems . reduce ( ( memo , item ) => {
421422 const itemId = _get ( item , keys . itemIdKey )
422423 const isDragging = itemId === draggingItem
423424 const isResizing = itemId === resizingItem
424425
425-
426426 let dimension = calculateDimensions ( {
427427 itemTimeStart : _get ( item , keys . itemTimeStartKey ) ,
428428 itemTimeEnd : _get ( item , keys . itemTimeEndKey ) ,
@@ -471,47 +471,53 @@ state
471471 * Get the the canvas area for a given visible time
472472 * Will shift the start/end of the canvas if the visible time
473473 * does not fit within the existing
474- * @param {number } visibleTimeStart
475- * @param {number } visibleTimeEnd
476- * @param {boolean } forceUpdateDimensions
477- * @param {* } items
478- * @param {* } groups
479- * @param {* } props
480- * @param {* } state
474+ * @param {number } visibleTimeStart
475+ * @param {number } visibleTimeEnd
476+ * @param {boolean } forceUpdateDimensions
477+ * @param {* } items
478+ * @param {* } groups
479+ * @param {* } props
480+ * @param {* } state
481481 */
482482export function calculateScrollCanvas (
483- visibleTimeStart ,
484- visibleTimeEnd ,
485- forceUpdateDimensions ,
486- items ,
487- groups ,
488- props ,
489- state ) {
483+ visibleTimeStart ,
484+ visibleTimeEnd ,
485+ forceUpdateDimensions ,
486+ items ,
487+ groups ,
488+ props ,
489+ state
490+ ) {
490491 const oldCanvasTimeStart = state . canvasTimeStart
491492 const oldZoom = state . visibleTimeEnd - state . visibleTimeStart
492-
493+ const newZoom = visibleTimeEnd - visibleTimeStart
493494 const newState = { visibleTimeStart, visibleTimeEnd }
494495
495496 // Check if the current canvas covers the new times
496497 const canKeepCanvas =
498+ newZoom === oldZoom &&
497499 visibleTimeStart >= oldCanvasTimeStart + oldZoom * 0.5 &&
498500 visibleTimeStart <= oldCanvasTimeStart + oldZoom * 1.5 &&
499501 visibleTimeEnd >= oldCanvasTimeStart + oldZoom * 1.5 &&
500502 visibleTimeEnd <= oldCanvasTimeStart + oldZoom * 2.5
501-
503+
502504 if ( ! canKeepCanvas || forceUpdateDimensions ) {
503- newState . canvasTimeStart = visibleTimeStart - ( visibleTimeEnd - visibleTimeStart )
505+ newState . canvasTimeStart =
506+ visibleTimeStart - ( visibleTimeEnd - visibleTimeStart )
504507 // The canvas cannot be kept, so calculate the new items position
505- Object . assign ( newState , stackItems (
506- items ,
507- groups ,
508- newState . canvasTimeStart ,
509- visibleTimeStart ,
510- visibleTimeEnd ,
511- state . width ,
512- props ,
513- state
514- ) )
508+ Object . assign (
509+ newState ,
510+ stackItems (
511+ items ,
512+ groups ,
513+ newState . canvasTimeStart ,
514+ visibleTimeStart ,
515+ visibleTimeEnd ,
516+ state . width ,
517+ props ,
518+ state
519+ )
520+ )
515521 }
516522 return newState
517523}
0 commit comments