-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Objects disappearing after second init(); #65
Comments
Found the solution! First, use the Then at around Line 124, Also a few more problems, and their solutions… Because the JavaScript doesn't kick in right away, you might notice a flicker where all the reveal content appears, disappears, then gets re-animated in. This is because the CSS loads first, then the JS, then the plugin kicks in. The solution is in your css, do init: function() {
var id;
self.elems = Array.prototype.slice.call( self.docElem.querySelectorAll( '[data-scroll-reveal]' ) );
self.elems.forEach(function ( el, i ) {
/**
* i is 0 initially, so let’s bump it so we start with 1
*/
i++;
id = el.getAttribute( 'data-sr-id' );
/**
* if id is undefined, assign a new one to self.data and
* to the DOM element (via the data-sr-style-id attribute)
*/
if ( !id ) {
id = self.serial++;
self.data[ id ] = {};
self.data[ id ].id = id;
el.setAttribute( 'data-sr-id', id );
}
else {
return;
}
var tempstyle = el.getAttribute( 'style' );
el.setAttribute('style', tempstyle+';visibility:visible;');
/**
* if no style property has been set, create one using the value from
* the element's existing style tag — otherwise set to false
*/
if ( !self.data[ id ].style ) {
self.data[ id ].style = el.getAttribute( 'style' );
if ( self.data[ id ].style ) {
self.data[ id ].style += ';';
} else {
self.data[ id ].style = '';
}
}
window.addEventListener( 'scroll', _eventHandler, false );
window.addEventListener( 'resize', _eventHandler, false );
});
self.eventBlocked = false;
self.animate( self.elems );
}, Note the return in the declaring part, that's so we don't re-init values we've already crawled (causing it to disappear) You can see a live example at http://rates.ca but won't be available till next launch next week Thanks for an awesome plugin! |
Awesome! Thanks @mclapa, I appreciate you taking the time. I’m working on getting this into the |
@mclapa Boom 💥 I’ve got these changes in the latest RC. Thanks again, and great work! |
Hello,
I noticed there's a bug when calling init() for the second time.
I have 2 async ajax calls, I never know which one is first, so my code looks a bit like this
Now I'm not sure if it has something to do with the animations being mid-way when the second init hits, but the items from the first init animate in, and after complete, their opacity is set to 0 and they disappear.
I have a feeling that it has something to do with the reveal-complete attribute only being set after the animate, and the second init runs before the attribute is set.
I've tried using the
v2.0.0-RC
branch (ie. Mockingbird) but I'm running into different problems which I'm now debugging.Thanks!
The text was updated successfully, but these errors were encountered: