Closed Electrofenster closed 9 years ago
Hi!
It's difficult to tell from only the code. There's two possible explanations:
If this doesn't resolve your issue, please try to create a jsfiddle to showcase it or create a permanent link where we can have a look. Also make sure you followed this guide: https://github.com/janpaepke/ScrollMagic/blob/master/CONTRIBUTING.md
@janpaepke I don't have any debug output or error in my console.
I made a jsfiddle with my problem: http://jsfiddle.net/gfhgybbL/1/
Well here's your problem:
The scene has no duration, so it will just play the animation when it's triggered.
Since it has neither offset
, nor triggerElement
set, it will trigger right on page load (and play the animation).
The triggerElement
you set in line 11 is invalid, because it doesn't exist.
That is something you would have seen in the console, if you used the development version instead of the minified production version of ScrollMagic, which is noted in the installation guide.
So bottom line: as I suspected -> the triggers were off. It becomes very obvious, when you use the debug extension (as I also suggested). See here: http://jsfiddle.net/eqv8hn38/
Now if you check the console (which I also suggested), aside from an error regarding the trigger element, you will see the message "invalid offset tween value: 20".
This is due to the fact, that you added the offset
option in the tween's definition, where it is in fact a ScrollMagic scene option.
So it should be defined before or after line 11.
Once you correct that, it doesnt start at the beginning anymore: http://jsfiddle.net/eqv8hn38/1/
Now my guess is your next question is going to be "why doesn't it work with fullpage?" The reason is this: The Fullpage plugin, like OnePageScroll, moves divs inside of a container using CSS instead of actually scrolling the page. So how to get it to work? That is more complicated, than you might think, because both plugins use transform and css animations by default. Sadly there is no progress update event for css animations so the only way to do it is to write your own update function.
Step1: disable css animations Step2: write a loop that checks for the current top position of the wrapper and updates ScrollMagic, if it changes. Step3: Give ScrollMagic a way of knowing how far the scroll is (since fullpage uses css positioning and will always return a scrollTop value of 0 for the div). To do that you can use a function to overwrite the scrollPos of ScrollMagic, just like it's been done in the mobile advanced example
And boom it works: http://jsfiddle.net/50cgweog/
hope this helps, J
P.S.: At this point you can re-enable CSS transforms to make use of the performance enhancement this brings (see here http://jsfiddle.net/50cgweog/1/). The only downside is that the trigger indicator and pins will not work anymore. This is due to a problem with fixed elements whose parents are transformed.
WoW, thanks for your great help. :+1: It works in my site too.
then, how to use the pines
I want to "zoom" my paper div in at #triggerScale but it doesn't work. The effect starts directly with the pageload :/
here is what I have. index.html:
main.js:
and my main.coffee