Skip to content

Commit

Permalink
Add "scroll to activity" to activity directive table context menu (#1433
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ivydeliz committed Nov 5, 2024
1 parent 971d44b commit 6fe7401
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/stores/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Tag } from '../types/tags';
import type { TimeRange } from '../types/timeline';
import gql from '../utilities/gql';
import { gqlSubscribable } from './subscribable';
import { getIntervalInMs } from '../utilities/time';

/* Writeable. */

Expand Down Expand Up @@ -115,13 +116,15 @@ export function setActivityEditingLocked(locked: boolean) {
activityEditingLocked.set(locked);
}

// follows similar pattern to TimelineViewControls.scrollToSelection
export function setViewTimeRangeAroundTime(timeInMs: number) {
const currentViewTimeRange = get(viewTimeRange);
const padding = (currentViewTimeRange.end - currentViewTimeRange.start)/2;
const maxRange = get(maxTimeRange);
viewTimeRange.set({
end: Math.min(maxRange.end, timeInMs + padding),
start: Math.max(maxRange.start, timeInMs - padding)
});

if (!isNaN(timeInMs) && (timeInMs < currentViewTimeRange.start || timeInMs > currentViewTimeRange.end)) {
const padding = (currentViewTimeRange.end - currentViewTimeRange.start) / 2;
const maxRange = get(maxTimeRange);
viewTimeRange.set({
end: Math.min(maxRange.end, timeInMs + padding),
start: Math.max(maxRange.start, timeInMs - padding)
});
}
}

0 comments on commit 6fe7401

Please sign in to comment.