File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -340,7 +340,9 @@ function ParallaxController() {
340
340
* @param {object } element
341
341
*/
342
342
this . removeElement = function ( element ) {
343
- const index = elements . indexOf ( element ) ;
343
+ // gets the index of the element to update based on id
344
+ const index = elements . findIndex ( el => el . id === element . id ) ;
345
+
344
346
if ( index !== - 1 ) {
345
347
elements . splice ( index , 1 ) ;
346
348
}
@@ -356,10 +358,12 @@ function ParallaxController() {
356
358
const index = elements . findIndex ( el => el . id === element . id ) ;
357
359
358
360
// create new element with options and replaces the old
359
- elements [ index ] = Object . assign ( { } , elements [ index ] , options ) ;
361
+ if ( index !== - 1 ) {
362
+ elements [ index ] = Object . assign ( { } , elements [ index ] , options ) ;
360
363
361
- // call update to set attributes and positions based on the new options
362
- this . update ( ) ;
364
+ // call update to set attributes and positions based on the new options
365
+ this . update ( ) ;
366
+ }
363
367
} ;
364
368
365
369
/**
You can’t perform that action at this time.
0 commit comments