You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: dev/src/ScrollMagic/Scene/update-params.js
+29-20
Original file line number
Diff line number
Diff line change
@@ -54,29 +54,38 @@ var updateTriggerElementPosition = function (suppressEvents) {
54
54
var
55
55
elementPos=0,
56
56
telem=_options.triggerElement;
57
-
if(_controller&&telem){
58
-
var
59
-
controllerInfo=_controller.info(),
60
-
containerOffset=_util.get.offset(controllerInfo.container),// container position is needed because element offset is returned in relation to document, not in relation to container.
61
-
param=controllerInfo.vertical ? "top" : "left";// which param is of interest ?
62
-
63
-
// if parent is spacer, use spacer position instead so correct start position is returned for pinned elements.
if(_controller&&(telem||_triggerPos>0)){// either an element exists or was removed and the triggerPos is still > 0
58
+
if(telem){// there currently a triggerElement set
59
+
if(telem.parentNode){// check if element is still attached to DOM
60
+
var
61
+
controllerInfo=_controller.info(),
62
+
containerOffset=_util.get.offset(controllerInfo.container),// container position is needed because element offset is returned in relation to document, not in relation to container.
63
+
param=controllerInfo.vertical ? "top" : "left";// which param is of interest ?
64
+
65
+
// if parent is spacer, use spacer position instead so correct start position is returned for pinned elements.
if(!controllerInfo.isDocument){// container is not the document root, so substract scroll Position to get correct trigger element position relative to scrollcontent
if(!controllerInfo.isDocument){// container is not the document root, so substract scroll Position to get correct trigger element position relative to scrollcontent
71
-
containerOffset[param]-=_controller.scrollPos();
78
+
}else{// there was an element, but it was removed from DOM
79
+
log(2,"WARNING: triggerElement was removed from DOM and will be reset to",undefined);
80
+
Scene.triggerElement(undefined);// unset, so a change event is triggered
0 commit comments