7
7
:draggable ="isDraggable ? 'true' : undefined"
8
8
@dragstart ="isDraggable && dnd.eventDragStart($event, event)"
9
9
@dragend ="isDraggable && dnd.eventDragEnd($event, event)" )
10
+ .vuecal__event-resizer.vuecal__event-resizer--top ( v-if ="isResizable" @dragstart.prevent.stop )
10
11
.vuecal__event-details
11
12
slot( v-if ="$slots['event.all-day']" name ="event.all-day" : event = "event" )
12
13
slot( v-else-if ="$slots[`event.${view.id}`]" : name= "`event.${view.id}`" : event = "event" )
17
18
span.vuecal__event-start {{ event._[`startTimeFormatted${config.twelveHour ? 12 : 24}`] }}
18
19
span.vuecal__event-end ( v-if ="!view.isMonth" ) - {{ event._[`endTimeFormatted${config.twelveHour ? 12 : 24}`] }}
19
20
.vuecal__event-content ( v-if ="!inAllDayBar" v-html ="event.content" )
20
- .vuecal__event-resizer ( v-if ="isResizable" @dragstart.prevent.stop )
21
+ .vuecal__event-resizer.vuecal__event-resizer--bottom ( v-if ="isResizable" @dragstart.prevent.stop )
21
22
transition( name ="vuecal-delete-btn" )
22
23
.vuecal__event-delete ( v-if ="event._.deleting" @click.stop ="event.delete(3)" ) Delete
23
24
</template >
@@ -40,7 +41,8 @@ const event = reactive(props.event)
40
41
const touch = reactive ({
41
42
dragging: false ,
42
43
resizing: false ,
43
- fromResizer: false , // If the drag originates from the resizer element.
44
+ fromBottomResizer: false , // If the drag originates from the resizer element.
45
+ fromTopResizer: false , // If the drag originates from the top resizer element.
44
46
holding: false , // When the event is clicked and hold for a certain amount of time.
45
47
holdTimer: null , // event click and hold detection.
46
48
startX: 0 , // The X coords at the start of the drag.
@@ -176,7 +178,9 @@ const eventListeners = computed(() => {
176
178
const onMousedown = e => {
177
179
const domEvent = e .touches ? .[0 ] || e // Handle click or touch event.
178
180
// If the event target is the resizer, set the resizing flag.
179
- touch .fromResizer = domEvent .target .matches (' .vuecal__event-resizer, .vuecal__event-resizer *' )
181
+ touch .fromBottomResizer = domEvent .target .matches (' .vuecal__event-resizer--bottom, .vuecal__event-resizer--bottom *' )
182
+ // Check if it's the top resizer
183
+ touch .fromTopResizer = domEvent .target .matches (' .vuecal__event-resizer--top, .vuecal__event-resizer--top *' )
180
184
181
185
const rect = eventEl .value .getBoundingClientRect ()
182
186
touch .startX = (e .touches ? .[0 ] || e).clientX - rect .left // Handle click or touch event coords.
@@ -202,7 +206,7 @@ const onDocMousemove = async e => {
202
206
const domEvent = e .touches ? .[0 ] || e // Handle click or touch event.
203
207
204
208
// Only the first touchmove to set the dragging flag.
205
- if (touch .fromResizer && ! touch .resizing ) {
209
+ if (( touch .fromBottomResizer || touch . fromTopResizer ) && ! touch .resizing ) {
206
210
touch .resizing = true
207
211
touch .resizingOriginalEvent = { ... event , _: { ... event ._ } }
208
212
globalTouchState .isResizingEvent = true // Add a CSS class on wrapper while resizing.
@@ -222,7 +226,7 @@ const onDocMousemove = async e => {
222
226
touch .movePercentageY = touch .moveY * 100 / height
223
227
}
224
228
225
- if (touch .fromResizer ) {
229
+ if (touch .fromBottomResizer || touch . fromTopResizer ) {
226
230
const { newStart , newEnd } = computeStartEnd (event )
227
231
228
232
// If there's an @event-resize external listener, call it and ask for resizing approval.
@@ -284,7 +288,8 @@ const onDocMouseup = async e => {
284
288
285
289
document .removeEventListener (e .type === ' touchend' ? ' touchmove' : ' mousemove' , onDocMousemove)
286
290
touch .resizing = false
287
- touch .fromResizer = false
291
+ touch .fromBottomResizer = false
292
+ touch .fromTopResizer = false
288
293
touch .dragging = false
289
294
290
295
touch .startX = 0
@@ -318,12 +323,16 @@ const computeStartEnd = event => {
318
323
}
319
324
320
325
let newStart = event .start
321
- let newEnd = new Date (startMidnight .getTime () + minutes * 60000 )
326
+ let newEnd = event .end
327
+ const newValue = new Date (startMidnight .getTime () + minutes * 60000 )
322
328
323
- // While resizing and event end is before event start.
324
- if (newEnd < touch .resizeStartDate ) {
325
- newStart = newEnd
326
- newEnd = touch .resizeStartDate
329
+ if (touch .fromTopResizer && newValue < event .end ) {
330
+ // When resizing from the top, modify the start time
331
+ newStart = newValue
332
+ }
333
+ if (touch .fromBottomResizer && newValue > event .start ) {
334
+ // When resizing from the bottom, modify the end time
335
+ newEnd = newValue
327
336
}
328
337
329
338
return { newStart, newEnd }
@@ -364,13 +373,24 @@ onBeforeUnmount(() => {
364
373
& -- resizing {z- index: 100 ;}
365
374
& - resizer {
366
375
position: absolute;
367
- inset: auto 0 0 ;
376
+ left: 0 ;
377
+ right: 0 ;
368
378
height: 8px ;
369
379
background- color: #fff;
370
380
opacity: 0.1 ;
371
381
transition: 0 .25s ;
372
382
cursor: ns- resize;
373
383
384
+ & -- top {
385
+ top: 0 ;
386
+ bottom: auto;
387
+ }
388
+
389
+ & -- bottom {
390
+ top: auto;
391
+ bottom: 0 ;
392
+ }
393
+
374
394
& : hover {opacity: 0.25 ;}
375
395
}
376
396
}
0 commit comments