Hi Jack, thanks for the welcome and answer!
I'm sorry for not answering quickly, I have been testing and trying to refine my example in order to make it minimal.
I guess I tried to wrap many things in a single request and as you mentioned, it turned out a little fuzzy to understand.
I hope it can be a little more clear now.
Basically I will have a large svg with many elements that will animate while scrolling. Besides, text and images will appear at certain positions, these elements are not part of the svg but are placed in html sections.
In my code example I just have an svg with some squares placed in different positions, on the other hand I have a set of sections on which I'm displaying text in front and images (with height of the size of the viewport) on the back of the svg content.
The svg part:
<svg id="svg-init" x="0px" y="0px" width="1024px"
height="2000px" viewBox="0 0 1024 2000" enable-background="new 0 0 1024 2000" xml:space="preserve">
<g id="square1">
<rect x="96" y="200" fill="#1A1AFF" width="344" height="223"/>
</g>
<g class="marker2">
<rect x="96" y="500" fill="#1A1AFF" width="50" height="100vh"/>
</g>
<g id="square2">
<rect x="96" y="700" fill="#FF390B" width="344" height="223"/>
</g>
<g class="marker3">
<rect x="96" y="1000" fill="#1A1AFF" width="50" height="100vh"/>
</g>
<g id="square3">
<rect x="96" y="1200" fill="#15FF31" width="344" height="223"/>
</g>
</svg>
The sections part:
<section id="section_01">
<!-- some content-->
</section>
<section id="section_02">
<!-- some content-->
</section>
<section id="section_03">
<!-- some content-->
</section>
The thing I'm having trouble to understand is how to trigger the svg animations in a synchronized manner with the text and images that I have in the sections tags.
After some tests I added (as part of the svg) other elements (squares) which I called marker2 and marker3 before the squares in order to use those markers only to trigger the squares movement, I'm not sure if this trick could be a good idea as it works depending on the height I set on these markers or the squares. (in the example above, the movement can bee seen working better when in full size).
Visually the operation works more or less as expected, i.e. the square's movement is triggered when each section appear on the viewport, however is kind of tricky to specify when to trigger the movement as I would like to specify that the square2 should start to move when the section_02 is visible (make the square appear always in the same position when the section is displayed). The marker's trick worked a little but is not so easy to see.
I'm wondering if maybe is possible, for instance, use an id of an html section as trigger and when the section appears in the viewport I could have control over the svg elements.
Thanks again for your help and hope it can be a little easier to understand!