-
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
scrollReveal on ajax call #125
Comments
Tty call |
Hey @edonbajrami The If you have only 1 AJAX call, then @ivansglazunov suggestion should be fine. If you have multiple AJAX calls, you’ll want to make sure you call |
I'm still having a problem with this. I'm calling
If I scroll up and down the page, nothing happens. If I run It's a reasonably complex site but I'm not doing anything special with the elements except for loading them in via AJAX. Sorry to comment on a closed issue but hopefully this will make more sense to you! |
@mrchimp Hmm, I’m gonna recommend you check out ScrollReveal 3 There’s a few differences (most of them outlined in that link), but the JavaScript API will give you better control and has been tested far more for complex situations (multiple viewports, asynchronous configurations, etc.) This is a very rough example, but you should be able to do something like this: $.ajax().done(function( data ){
sr.reveal( '.sampleClass', sampleConfig );
sr.init();
}); |
I subscribe to this topic, it is very necessary, but it is impossible to implement. My demonstration — https://youtu.be/9Y4Sgd4UPrU. Code: (function($) {
Drupal.behaviors.ScrollRev = {
attach: function (context, settings) {
var config = {
reset: true
}
window.sr = new scrollReveal( config ).reveal('.views-row').init();
}
};
})(jQuery); and $('.ui-widget-overlay:last').click(function (event) {
if ($(event.target).hasClass('ui-widget-overlay')) {
$dialogContent.dialog('close');
sr.init()
}
});
Drupal.ajax[linkId] = new Drupal.ajax(linkId, link, {
progress: {type: 'throbber'},
url: $link.attr('href'),
event: 'click',
submit: {
js: true,
autodialog_link_id: linkId,
autodialog_options: JSON.stringify(options)
},
beforeSerialize: function (xmlhttprequest, options) {
options.url = $link.attr('href');
$('body').addClass('autodialog-loading');
Drupal.ajax.prototype.beforeSerialize.apply(this, arguments);
},
success: function (response, status) {
$('body').removeClass('autodialog-loading');
Drupal.ajax.prototype.success.apply(this, arguments);
sr.init()
},
});
}, What am i doing wrong? |
It looks like your original objects are being dropped from the ScrollReveal element store, which is why they no longer respond to the event handler when you scroll back up… This leads me to believe you are instantiating ScrollReveal more than once. I’m not familiar with Drupal, but it I’m guessing the bit of code below is running each time you make an aynsc request… which means (function($) {
Drupal.behaviors.ScrollRev = {
attach: function (context, settings) {
var config = { reset: true }
window.sr = new scrollReveal( config ).reveal('.views-row').init();
}
};
})(jQuery); If I were you, the first thing I would try would be to check if (function($) {
Drupal.behaviors.ScrollRev = {
attach: function (context, settings) {
if ( !sr ){
window.sr = new scrollReveal({ reset: true });
}
sr.reveal('.views-row').init();
}
};
})(jQuery); Again, I’m not familiar with Drupal, so I don't know the order in which all this fires… but this assumes that Hopefully this makes sense, and moves you in the right direction. 🙇 |
@jlmakes |
@jlmakes |
@jlmakes, Is it possible anywhere to download the latest version of the first branch of the library? It is like working with Drupal ... |
@evgenyshev really, hmm... is there somewhere this uploaded that I can help troubleshoot? I believe we’re really close.
Which version number? |
@jlmakes any 1.x |
Sure @evgenyshev, but be warned, I can provide absolutely no support for the beta—here is a link to https://github.com/LoicMahieu/scrollReveal.js-0.1.3 Related to #89 |
@jlmakes Unfortunately, this version does not work properly with ajax on my site, and also breaks jQuery Dialog. |
@jlmakes |
@evgenyshev I think we are close! If you have the time, find a way to put your demo online with the issue. I would love to get this sorted for you, and future users! 🙇 |
See now one of the projects on which I would like to use your library (really like to) - http://krd.nidbin.ru/search?query=краснодар As has been said, to connect your script in two ways. Who is connected through a special module. It should work with the version 2.x.x. The code module can be seen here - http://ftp.drupal.org/files/projects/scrollreveal-7.x-2.x-dev.zip. Animation applied to elements [.company-search .views-row]
Version jQuery 1.10. Tried different (since 1.8). No changes. |
@evgenyshev If you do |
@jlmakes You will not believe, but it works!! Thank you very much! Today, you are my God! :) |
Update Jan 13th, 2016: Using version 3.x, managing asynchronous content got a lot easier and more reliable. The Example using ScrollReveal 3: <!-- index.html -->
<div id="container">
<div class="foo">foo</div>
<div class="foo">foo</div>
<div class="foo">foo</div>
</div>
<!-- ajax.html -->
<div class="foo">foo async</div>
<div class="foo">foo async</div>
<div class="foo">foo async</div> var fooContainer, content, sr, xmlhttp;
fooContainer = document.getElementById('fooContainer');
sr = ScrollReveal();
sr.reveal( '.foo', { container: fooContainer } );
// Setup a new asynchronous request...
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if ( xmlhttp.readyState == XMLHttpRequest.DONE ) {
if ( xmlhttp.status == 200 ) {
// Turn our response into HTML...
var content = document.createElement('div');
content.innerHTML = xmlhttp.responseText;
content = content.childNodes;
// Add each element to the DOM...
for ( var i = 0; i < content.length; i++ ) {
fooContainer.appendChild( content[ i ]);
};
// Finally!
sr.sync();
}
}
}
xmlhttp.open('GET', 'ajax.html', true);
xmlhttp.send(); |
scrollReveal is not working with instaFeed.js, after load data on scroll is not working ? Is there any solution to resolve this problem ?
The text was updated successfully, but these errors were encountered: