Unfortunately it's just not feasible to make ScrollToPlugin accommodate that automatically. There's no way it could understand which elements are affected by which ScrollTriggers. It's essential that you, as the builder of the page, provide that information. But here's a helper function you could try - it lets you create several lookups that get added together into one big lookup. Splitting them up like this allows you to segregate elements according to whether or not they're in a containerAnimation and/or pinnedContainer:
function getScrollLookup(targets, {start, pinnedContainer, containerAnimation}) {
targets = gsap.utils.toArray(targets);
let initted,
triggers = targets.map((el, i) => ScrollTrigger.create({
trigger: el,
start: start || "top top",
pinnedContainer: pinnedContainer,
refreshPriority: -10,
onRefresh(self) {
if (initted && Math.abs(self.start) > 999999) {
triggers[i].kill();
triggers[i] = ScrollTrigger.create({
trigger: el,
start: start || "start start",
pinnedContainer: pinnedContainer,
refreshPriority: -10,
});
}
},
containerAnimation: containerAnimation
})),
st = containerAnimation && containerAnimation.scrollTrigger,
lookups = [],
lookup = target => {
let t = gsap.utils.toArray(target)[0],
i = targets.indexOf(t);
if (i < 0) {
for (i = 0; i < lookups.length; i++) {
if (lookups[i].targets.indexOf(t) !== -1) {
return lookups[i](t);
}
}
return console.warn("target not found", target);
}
return triggers[i].vars.containerAnimation ? st.start + (triggers[i].start / containerAnimation.duration()) * (st.end - st.start) : triggers[i].start;
};
lookup.targets = targets;
lookup.add = (targets, config) => {
lookups.push(getScrollLookup(targets, config));
return lookup;
};
initted = true;
return lookup;
}
So you'd use it like:
let lookup = getScrollLookup("section.project", { containerAnimation: tween, pinnedContainer: el });
lookup.add("section.other", {}); // no containerAnimation or pinnedContainer
lookup.add("section.pinned", {pinnedContainer: el}); // just a pinned container
// then later...
let position = lookup(".any-of-the-above-elements");
Hopefully that helps.