@@ -221,14 +221,24 @@ var bounding_box = Object();
221
221
222
222
// Build bounding box (since multiple items can be selected)
223
223
function setBoundingBox ( scope , item , item_type = "clip" ) {
224
- var scrolling_tracks = $ ( "#scrolling_tracks" ) ;
225
- var vert_scroll_offset = scrolling_tracks . scrollTop ( ) ;
226
- var horz_scroll_offset = scrolling_tracks . scrollLeft ( ) ;
227
-
228
- var item_bottom = item . position ( ) . top + item . height ( ) + vert_scroll_offset ;
229
- var item_top = item . position ( ) . top + vert_scroll_offset ;
230
- var item_left = item . position ( ) . left + horz_scroll_offset ;
231
- var item_right = item . position ( ) . left + horz_scroll_offset + item . width ( ) ;
224
+ let scrolling_tracks = $ ( "#scrolling_tracks" ) ;
225
+ let vert_scroll_offset = scrolling_tracks . scrollTop ( ) ;
226
+ let horz_scroll_offset = scrolling_tracks . scrollLeft ( ) ;
227
+ let item_bottom = 0 ;
228
+ let item_top = 0 ;
229
+ let item_left = 0 ;
230
+ let item_right = 0 ;
231
+
232
+ if ( item && item . position ( ) ) {
233
+ item_bottom = item . position ( ) . top + item . height ( ) + vert_scroll_offset ;
234
+ item_top = item . position ( ) . top + vert_scroll_offset ;
235
+ item_left = item . position ( ) . left + horz_scroll_offset ;
236
+ item_right = item . position ( ) . left + horz_scroll_offset + item . width ( ) ;
237
+ } else {
238
+ // Protect against invalid item (sentry)
239
+ // TODO: Determine what causes an invalid item to be passed into this function
240
+ return ;
241
+ }
232
242
233
243
if ( jQuery . isEmptyObject ( bounding_box ) ) {
234
244
bounding_box . left = item_left ;
@@ -245,8 +255,8 @@ function setBoundingBox(scope, item, item_type="clip") {
245
255
if ( item_right > bounding_box . right ) { bounding_box . right = item_right ; }
246
256
247
257
// compare height and width of bounding box (take the largest number)
248
- var height = bounding_box . bottom - bounding_box . top ;
249
- var width = bounding_box . right - bounding_box . left ;
258
+ let height = bounding_box . bottom - bounding_box . top ;
259
+ let width = bounding_box . right - bounding_box . left ;
250
260
if ( height > bounding_box . height ) { bounding_box . height = height ; }
251
261
if ( width > bounding_box . width ) { bounding_box . width = width ; }
252
262
}
@@ -268,12 +278,12 @@ function setBoundingBox(scope, item, item_type="clip") {
268
278
// Unless playhead mode, where we don't want to ignore any selected clips
269
279
bounding_box . selected_ids = { } ;
270
280
if ( item_type !== "playhead" ) {
271
- for ( var clip_index = 0 ; clip_index < scope . project . clips . length ; clip_index ++ ) {
281
+ for ( let clip_index = 0 ; clip_index < scope . project . clips . length ; clip_index ++ ) {
272
282
if ( scope . project . clips [ clip_index ] . selected ) {
273
283
bounding_box . selected_ids [ scope . project . clips [ clip_index ] . id ] = true ;
274
284
}
275
285
}
276
- for ( var effect_index = 0 ; effect_index < scope . project . effects . length ; effect_index ++ ) {
286
+ for ( let effect_index = 0 ; effect_index < scope . project . effects . length ; effect_index ++ ) {
277
287
if ( scope . project . effects [ effect_index ] . selected ) {
278
288
bounding_box . selected_ids [ scope . project . effects [ effect_index ] . id ] = true ;
279
289
}
@@ -367,7 +377,7 @@ global_primes = new Set();
367
377
* Stores primes in a set for better performance in the future.
368
378
* If some primes have been found, start with that list,
369
379
* and check the remaining numbers up to n.
370
- * @param {any number } n
380
+ * @param {any number } n
371
381
* @returns the list of all primes less than n
372
382
*/
373
383
function primesUpTo ( n ) {
@@ -394,7 +404,7 @@ function primesUpTo(n) {
394
404
/**
395
405
* Every integer is either prime,
396
406
* is the product of some list of primes.
397
- * @param {integer to factor } n
407
+ * @param {integer to factor } n
398
408
* @returns the list of prime factors of n
399
409
*/
400
410
function primeFactorsOf ( n ) {
@@ -417,13 +427,13 @@ function primeFactorsOf(n) {
417
427
* From the pixels per second of the project,
418
428
* Find a number of frames between each ruler mark,
419
429
* such that the tick marks remain at least 50px apart.
420
- *
430
+ *
421
431
* Increases the number of frames by factors of FPS.
422
432
* This way each tick should land neatly on a second mark
423
- * @param {Pixels per second } pps
424
- * @param fps_num
425
- * @param fps_den
426
- * @returns
433
+ * @param {Pixels per second } pps
434
+ * @param fps_num
435
+ * @param fps_den
436
+ * @returns
427
437
*/
428
438
function framesPerTick ( pps , fps_num , fps_den ) {
429
439
fps = fps_num / fps_den ;
@@ -434,7 +444,7 @@ function framesPerTick(pps, fps_num, fps_den) {
434
444
while ( pixels ( ) < 40 ) {
435
445
frames *= factors . shift ( ) || 2 ;
436
446
}
437
-
447
+
438
448
return frames ;
439
449
}
440
450
0 commit comments