Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: i#3133 improve sidebar drag usability #503

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@ Copyright (c) 2023-present Kaleidos INC
}

.dragbar {
block-size: 4rem;
border: solid 3px transparent;
border: solid 6px transparent;
display: flex;
flex-direction: column;
inline-size: 1px;
inset-block-start: 50%;
inset-block-end: 0;
inset-block-start: 0;
justify-content: center;
position: absolute;

&::after {
background: var(--color-gray40);
block-size: 100%;
block-size: 4rem;
border-radius: 2px;
content: "";
inline-size: 1px;
inline-size: 2px;
inset-inline-start: -1px;
position: absolute;
transition: background-color 0.3s ease-in;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
*ngIf="showDragbar()"
class="dragbar"
tgStoryWrapperSideViewResize
(tgResizeStart)="isDragging(true)"
(tgResizeEnd)="isDragging(false)"
(tgResizeStart)="isDragging($event, true)"
(tgResizeEnd)="isDragging($event, false)"
(tgResizeMove)="dragMove(dragHandle, $event)"></div>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class ProjectFeatureStoryWrapperSideViewComponent implements OnChanges {
public minWidthCollapsed = 440;
public minWidthUncollapsed = 500;
public widthToForceCollapse = 500;
public dragInitialPosition = 0;

constructor(
private store: Store,
Expand All @@ -84,14 +85,19 @@ export class ProjectFeatureStoryWrapperSideViewComponent implements OnChanges {
}

public dragMove(dragHandle: HTMLElement, event: MouseEvent) {
this.sidepanelWidth = window.innerWidth - event.clientX;
this.sidepanelWidth =
window.innerWidth - event.clientX - this.dragInitialPosition;
dragHandle.style.transform = 'translate(0, 0)';
}

public isDragging(isDragging: boolean) {
public isDragging(event: MouseEvent, isDragging: boolean) {
this.dragging = isDragging;

if (!isDragging) {
if (isDragging && this.sidepanel) {
this.dragInitialPosition =
this.sidepanel.nativeElement.getBoundingClientRect().x - event.clientX;
} else {
this.dragInitialPosition = 0;
this.localStorage.set('story_width', this.sidepanelWidth);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class StoryWrapperSideViewDirective {
}

this.disableEditorPointerEvents();
this.tgResizeStart.emit();
this.tgResizeStart.emit(event);

this.subscriptionMousemove = fromEvent(document.body, 'mousemove')
.pipe(untilDestroyed(this), throttleTime(0, animationFrameScheduler))
Expand Down