@@ -109,7 +109,7 @@ export default defineComponent({
109
109
* Get pixel position for giver time
110
110
*/
111
111
function getTimePosition (time : number ) {
112
- return (time - nonReactiveState .minTime .value ) / (nonReactiveState .endTime .value - nonReactiveState .startTime .value ) * app . view . width
112
+ return (time - nonReactiveState .minTime .value ) / (nonReactiveState .endTime .value - nonReactiveState .startTime .value ) * getAppWidth ()
113
113
}
114
114
115
115
// Reset
@@ -178,8 +178,8 @@ export default defineComponent({
178
178
// Manual painting
179
179
if (app .renderer .type === PIXI .RENDERER_TYPE .WEBGL ) {
180
180
mainRenderTexture = PIXI .RenderTexture .create ({
181
- width: app . view . width / window . devicePixelRatio ,
182
- height: app . view . height / window . devicePixelRatio ,
181
+ width: getAppWidth () ,
182
+ height: getAppHeight () ,
183
183
resolution: window .devicePixelRatio ,
184
184
})
185
185
mainRenderTexture .framebuffer .multisample = PIXI .MSAA_QUALITY .LOW
@@ -197,6 +197,14 @@ export default defineComponent({
197
197
app .destroy ()
198
198
})
199
199
200
+ function getAppWidth () {
201
+ return app .view .width / window .devicePixelRatio
202
+ }
203
+
204
+ function getAppHeight () {
205
+ return app .view .height / window .devicePixelRatio
206
+ }
207
+
200
208
// Manual painting (draw)
201
209
202
210
let drawScheduled = false
@@ -287,7 +295,7 @@ export default defineComponent({
287
295
const x = getTimePosition (marker .time )
288
296
marker .x = x
289
297
markerContainer .moveTo (x , 0 )
290
- markerContainer .lineTo (x , app . view . height )
298
+ markerContainer .lineTo (x , getAppHeight () )
291
299
}
292
300
markerContainer .x = horizontalScrollingContainer .x
293
301
}
@@ -419,7 +427,7 @@ export default defineComponent({
419
427
function drawLayerBackground (layerId : Layer [' id' ], alpha = 1 ) {
420
428
const { layer } = layersMap [layerId ]
421
429
layerHoverEffect .beginFill (layer .color , alpha )
422
- layerHoverEffect .drawRect (0 , getLayerY (layer ), app . view . width , (layer .height + 1 ) * LAYER_SIZE )
430
+ layerHoverEffect .drawRect (0 , getLayerY (layer ), getAppWidth () , (layer .height + 1 ) * LAYER_SIZE )
423
431
}
424
432
425
433
watch (hoverLayerId , () => {
@@ -1092,14 +1100,14 @@ export default defineComponent({
1092
1100
timeCursor .clear ()
1093
1101
timeCursor .lineStyle (1 , 0x888888 , 0.2 )
1094
1102
timeCursor .moveTo (0.5 , 0 )
1095
- timeCursor .lineTo (0.5 , app . view . height )
1103
+ timeCursor .lineTo (0.5 , getAppHeight () )
1096
1104
}
1097
1105
1098
1106
function updateCursorPosition (event : FederatedPointerEvent ) {
1099
1107
const { globalX } = event
1100
1108
timeCursor .x = globalX
1101
1109
timeCursor .visible = true
1102
- cursorTime .value = globalX / app . view . width * (endTime .value - startTime .value ) + startTime .value
1110
+ cursorTime .value = globalX / getAppWidth () * (endTime .value - startTime .value ) + startTime .value
1103
1111
}
1104
1112
1105
1113
function clearCursor () {
@@ -1122,7 +1130,7 @@ export default defineComponent({
1122
1130
if (! timeGrid .visible || ! app .view .width ) return
1123
1131
1124
1132
const size = endTime .value - startTime .value
1125
- const ratio = size / app . view . width
1133
+ const ratio = size / getAppWidth ()
1126
1134
let timeInterval = 10
1127
1135
let width = timeInterval / ratio
1128
1136
@@ -1141,9 +1149,9 @@ export default defineComponent({
1141
1149
1142
1150
timeGrid .clear ()
1143
1151
timeGrid .lineStyle (1 , 0x888888 , 0.075 )
1144
- for (let x = - offset ; x < app . view . width ; x += width ) {
1152
+ for (let x = - offset ; x < getAppWidth () ; x += width ) {
1145
1153
timeGrid .moveTo (x + 0.5 , 0 )
1146
- timeGrid .lineTo (x + 0.5 , app . view . height )
1154
+ timeGrid .lineTo (x + 0.5 , getAppHeight () )
1147
1155
}
1148
1156
}
1149
1157
@@ -1168,7 +1176,7 @@ export default defineComponent({
1168
1176
}
1169
1177
1170
1178
function updateCamera () {
1171
- horizontalScrollingContainer .x = - ( startTime . value - minTime . value ) / ( endTime . value - startTime .value ) * app . view . width
1179
+ horizontalScrollingContainer .x = - getTimePosition ( nonReactiveState . startTime .value )
1172
1180
drawLayerBackgroundEffects ()
1173
1181
drawTimeGrid ()
1174
1182
drawMarkers ()
@@ -1185,7 +1193,7 @@ export default defineComponent({
1185
1193
1186
1194
function onMouseWheel (event : FederatedWheelEvent ) {
1187
1195
const size = endTime .value - startTime .value
1188
- const viewWidth = app . view . width
1196
+ const viewWidth = getAppWidth ()
1189
1197
1190
1198
if (! event .ctrlKey && ! event .altKey ) {
1191
1199
const centerRatio = event .globalX / viewWidth
@@ -1295,7 +1303,7 @@ export default defineComponent({
1295
1303
1296
1304
// Horizontal
1297
1305
const size = endTime .value - startTime .value
1298
- const viewWidth = app . view . width
1306
+ const viewWidth = getAppWidth ()
1299
1307
const delta = deltaX / viewWidth * size
1300
1308
let start = startTime .value = startDragTime + delta
1301
1309
if (start < minTime .value ) {
@@ -1333,12 +1341,12 @@ export default defineComponent({
1333
1341
// @ts-expect-error PIXI type is missing queueResize
1334
1342
app .queueResize ()
1335
1343
setTimeout (() => {
1336
- mainRenderTexture ?.resize (app . view . width / window . devicePixelRatio , app . view . height / window . devicePixelRatio )
1337
- queueEventsUpdate ()
1338
- drawLayerBackgroundEffects ()
1339
- drawTimeCursor ()
1340
- drawTimeGrid ()
1341
- draw ()
1344
+ mainRenderTexture ?.resize (getAppWidth (), getAppHeight () )
1345
+ queueEventsUpdate ()
1346
+ drawLayerBackgroundEffects ()
1347
+ drawTimeCursor ()
1348
+ drawTimeGrid ()
1349
+ draw ()
1342
1350
}, 100 )
1343
1351
}
1344
1352
0 commit comments