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() {
340340 * @param {object } element
341341 */
342342 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+
344346 if ( index !== - 1 ) {
345347 elements . splice ( index , 1 ) ;
346348 }
@@ -356,10 +358,12 @@ function ParallaxController() {
356358 const index = elements . findIndex ( el => el . id === element . id ) ;
357359
358360 // 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 ) ;
360363
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+ }
363367 } ;
364368
365369 /**
You can’t perform that action at this time.
0 commit comments