diff --git a/src/calendar-app/calendar/gui/eventeditor-view/AttendeeListEditor.ts b/src/calendar-app/calendar/gui/eventeditor-view/AttendeeListEditor.ts index d9b77df1085e..f7a438bf0923 100644 --- a/src/calendar-app/calendar/gui/eventeditor-view/AttendeeListEditor.ts +++ b/src/calendar-app/calendar/gui/eventeditor-view/AttendeeListEditor.ts @@ -50,7 +50,7 @@ export class AttendeeListEditor implements Component { const { whoModel } = attrs.model.editModels const organizer = whoModel.organizer return [ - m(".flex-grow.flex.flex-column.gap-vpad.pb.pt.box-content.fit-height", { style: { width: px(attrs.width) } }, [ + m(".flex-grow.flex.flex-column.gap-vpad.pb.pt.fit-height", { style: { width: px(attrs.width) } }, [ this.renderOrganizer(attrs.model, organizer), m(".flex.flex-column.gap-vpad-s", [ m("small.uppercase.b.text-ellipsis", { style: { color: theme.navigation_button } }, lang.get("guests_label")), diff --git a/src/calendar-app/calendar/gui/eventeditor-view/CalendarEventEditView.ts b/src/calendar-app/calendar/gui/eventeditor-view/CalendarEventEditView.ts index 1789f78be0a1..a3479ce54e93 100644 --- a/src/calendar-app/calendar/gui/eventeditor-view/CalendarEventEditView.ts +++ b/src/calendar-app/calendar/gui/eventeditor-view/CalendarEventEditView.ts @@ -26,6 +26,7 @@ import { RepeatRuleEditor, RepeatRuleEditorAttrs } from "./RepeatRuleEditor.js" import type { CalendarRepeatRule } from "../../../../common/api/entities/tutanota/TypeRefs.js" import { formatRepetitionEnd, formatRepetitionFrequency } from "../eventpopup/EventPreviewView.js" import { TextFieldType } from "../../../../common/gui/base/TextField.js" +import { DefaultAnimationTime } from "../../../../common/gui/animation/Animations.js" export type CalendarEventEditViewAttrs = { model: CalendarEventModel @@ -73,7 +74,8 @@ export class CalendarEventEditView implements Component = stream(true) private dialogHeight: number | null = null - private pageStreamListener: stream | null + private pageWidth: number = -1 + private translate = 0 constructor(vnode: Vnode) { this.timeFormat = vnode.attrs.timeFormat @@ -87,14 +89,26 @@ export class CalendarEventEditView implements Component { - this.transitionTo(newPage) + + vnode.attrs.currentPage.map((page) => { + this.hasAnimationEnded = false + + if (page === EditorPages.MAIN) { + this.allowRenderMainPage(true) + this.translate = 0 + } }) + this.allowRenderMainPage.map((allowRendering) => { return this.handleEditorStatus(allowRendering, vnode) }) } + onremove(vnode: Vnode) { + vnode.attrs.currentPage.end(true) + this.allowRenderMainPage.end(true) + } + private handleEditorStatus(allowRendering: boolean, vnode: Vnode) { if (allowRendering && vnode.attrs.currentPage() === EditorPages.MAIN) { if (vnode.attrs.descriptionEditor.editor.domElement) { @@ -108,25 +122,25 @@ export class CalendarEventEditView implements Component): any { this.pagesWrapperDomElement = vnode.dom as HTMLElement this.pagesWrapperDomElement.addEventListener("transitionend", () => { if (vnode.attrs.currentPage() !== EditorPages.MAIN) { - this.allowRenderMainPage(false) + setTimeout(() => { + this.allowRenderMainPage(false) + }, DefaultAnimationTime) m.redraw() return } this.transitionPage = vnode.attrs.currentPage() this.hasAnimationEnded = true - this.allowRenderMainPage(true) - m.redraw() + + setTimeout(() => { + this.allowRenderMainPage(true) + m.redraw() + }, DefaultAnimationTime) }) } @@ -136,10 +150,25 @@ export class CalendarEventEditView implements Component): Children { - return m(".flex.gap-vpad-xxl.fit-content.transition-transform", [this.renderMainPage(vnode), this.renderPage(vnode)]) + return m( + ".flex.gap-vpad-xxl.fit-content.transition-transform", + { + style: { + transform: `translateX(${this.translate}px)`, + }, + }, + [this.renderMainPage(vnode), this.renderPage(vnode)], + ) } private renderPage(vnode: Vnode) { @@ -155,7 +184,7 @@ export class CalendarEventEditView implements Component { - navigationCallback(EditorPages.REPEAT_RULES) + this.transitionTo(EditorPages.REPEAT_RULES, navigationCallback) }, disabled, class: disabled ? "disabled cursor-disabled" : "", @@ -260,6 +289,13 @@ export class CalendarEventEditView implements Component unknown) { + this.hasAnimationEnded = false + this.transitionPage = target + this.translate = -(this.pageWidth + size.vpad_xxl) + navigationCallback(target) + } + private renderGuestsNavButton({ navigationCallback, model }: CalendarEventEditViewAttrs): Children { return m( Card, @@ -277,7 +313,7 @@ export class CalendarEventEditView implements Component { - navigationCallback(EditorPages.GUESTS) + this.transitionTo(EditorPages.GUESTS, navigationCallback) }, }, [ @@ -452,8 +488,8 @@ export class CalendarEventEditView implements Component navigationCallback(EditorPages.MAIN), } satisfies RepeatRuleEditorAttrs) } - private getPageWidth() { - if (!this.pagesWrapperDomElement) return 0 - const parentComputedStyle = getComputedStyle(this.pagesWrapperDomElement.parentElement!) - return Number(parentComputedStyle.width.slice(0, -2)) - Number(parentComputedStyle.paddingLeft.slice(0, -2)) * 2 - } - - private transitionTo(targetPage: EditorPages) { - if (!this.pagesWrapperDomElement) return - - this.hasAnimationEnded = false - - if (targetPage === EditorPages.MAIN) { - this.allowRenderMainPage(true) - this.pagesWrapperDomElement.style.transform = "translateX(0px)" - this.pagesWrapperDomElement.style.webkitTransform = "translateX(0px)" - return - } - - this.transitionPage = targetPage - const parentComputedStyle = getComputedStyle(this.pagesWrapperDomElement) - const pageWidth = this.getPageWidth() - const gapBetweenPages = Number(parentComputedStyle.gap.slice(0, -2)) - this.pagesWrapperDomElement.style.transform = `translateX(-${pageWidth + gapBetweenPages}px)` - this.pagesWrapperDomElement.style.webkitTransform = `translateX(-${pageWidth + gapBetweenPages}px)` - } - private getTranslatedRepeatRule(rule: CalendarRepeatRule | null, isAllDay: boolean): string { if (rule == null) return lang.get("calendarRepeatIntervalNoRepeat_label") diff --git a/src/calendar-app/calendar/gui/eventeditor-view/RepeatRuleEditor.ts b/src/calendar-app/calendar/gui/eventeditor-view/RepeatRuleEditor.ts index efd4bdc01694..952a5bd3e8ee 100644 --- a/src/calendar-app/calendar/gui/eventeditor-view/RepeatRuleEditor.ts +++ b/src/calendar-app/calendar/gui/eventeditor-view/RepeatRuleEditor.ts @@ -254,6 +254,12 @@ export class RepeatRuleEditor implements Component { this.intervalExpanded = true } }, + onblur: (event: FocusEvent) => { + if (isNaN(this.repeatInterval)) { + this.repeatInterval = this.numberValues[0].value + this.updateCustomRule(attrs.model, { interval: this.repeatInterval }) + } + }, style: { textAlign: "center", },