I added some jQuery lines in wordpress, but they don't work. Like you can see on the screenshots, my jQuery is present on the page, and there is no error in the console.
Here I tried a script that put a background on the menu after the scroll, but this don't work, nothing happen, the class "solid" is not added.
Try disabling the smooth scrolling, the smooth scroll library may hijack the scroll event.
Regarding images: maybe the images don't appear because of a well known incompatibility between WPBakery and AJAX page loading. If you are using the grenada wpbakery child theme we provide in our main package - you may solve this pb, have you tried it?
Quentin, you need to read carefully the smooth scrollbar documentation, the way they calculate the scrolling position and then do whatever you want to do with the scrolling.
just to give you an ideea
function listener(status) {
console.log('this is the x offset' + status.offset.x); } scrollbar.addListener(listener);
where status is an object with the following structure:
Thanks, but I found another solution using ScrollMagic.
I wrote this in script.js to add a css class to the header :
var headerScene = new ScrollMagic.Scene({
triggerElement: '#main-content',
triggerHook: 0,
})
.setClassToggle("header", "solid") // add class to reveal
.addTo(controller);
And added "headerScene.refresh()" in this condition to make the smooth scroll work with this class change :
Hello !
I know that the problem of images not loading can be corrected by disable Ajax in the options, and it's what I done.
But I really want to use the Ajax loading, and I need your help to correct that image loading problem. Is it possible ?
Thank you !
I also have another problem.
I added some jQuery lines in wordpress, but they don't work. Like you can see on the screenshots, my jQuery is present on the page, and there is no error in the console.
Here I tried a script that put a background on the menu after the scroll, but this don't work, nothing happen, the class "solid" is not added.
Can you help me with that please ?
Try disabling the smooth scrolling, the smooth scroll library may hijack the scroll event.
Regarding images: maybe the images don't appear because of a well known incompatibility between WPBakery and AJAX page loading. If you are using the grenada wpbakery child theme we provide in our main package - you may solve this pb, have you tried it?
Thank you.
Clapat Support
https://www.clapat.com/
Review Envato Item Support Policy
Thank you !
I now use the wpbakery child theme and there is now no problems with image loads using AJAX.
I disabled smooth scrolling and now the scroll event work.
But how can I do if I really want the smooth scroll effect and my custom JS scroll events ? There is a solution ?
Hi Quentin,
Then you have to dig a bit more into smooth scrollbar documentation and add a listener to its scroll events:
https://github.com/idiotWu/smooth-scrollbar/blob/develop/docs/api.md#scrollbaraddlistener
Thank you.
Clapat Support
https://www.clapat.com/
Review Envato Item Support Policy
Thanks for your answer.
I tried to do it myself, but I don't understand how it work, my skills in JS and jQuery are limited.
Can I charge you to do it and to explain me in details how you do please ? I want to know how to do if I have other listeners to add on scroll.
Hi Quentin,
the smooth scrollbar is initialized in /js/scripts.js in two places:
function FirstLoad() and PortfolioPackery() as
var elem = document.querySelector("#content-scroll");
var scrollbar = Scrollbar.init(elem,
{
renderByPixels: true,
damping:0.05
});
so following the example in the documentation
you can add immediately after
where status is an object with the following structure:
type ScrollStatus = {
// equal to `scrollbar.offset`
offset: {
x: number,
y: number,
},
// equal to `scrollbar.limit`
limit: {
x: number,
y: number,
},
};
so inside the function you can read the scrolling offset.
Thank you.
Clapat Support
https://www.clapat.com/
Review Envato Item Support Policy
Thank you for your help but I don't understand how to do.
I wrote :
just after :
var elem = document.querySelector("#content-scroll");
var scrollbar = Scrollbar.init(elem,
{
renderByPixels: true,
damping:0.05
});
But what do I write after :
Where do I write :
type ScrollStatus = {
// equal to `scrollbar.offset`
offset: {
x: number,
y: number,
},
// equal to `scrollbar.limit`
limit: {
x: number,
y: number,
},
};
And where do I write my function used to change the background of the menu :
jQuery(document).ready(function() {
jQuery(window).scroll(function() {
if(jQuery(this).scrollTop() > jQuery(window).height()-60) {
jQuery('header').addClass('solid');
} else {
jQuery('header').removeClass('solid');
}
});
});
Like I said, my skills in jQuery and js are limited, if I know precisely how to do I can understand, but actually I don't understand.
Can you help me please ? Thank you.
In other words, I think I actually don't have the skills to make this, I don't understand what to do, but I want to understand.
So maybe if you can help me a bit more, I would appreciate it.
Thank you for your help.
Quentin, you need to read carefully the smooth scrollbar documentation, the way they calculate the scrolling position and then do whatever you want to do with the scrolling.
just to give you an ideea
function listener(status) {
console.log('this is the x offset' + status.offset.x);
}
scrollbar.addListener(listener);
where status is an object with the following structure:
type ScrollStatus = {
// equal to `scrollbar.offset`
offset: { x: number, y: number, },
// equal to `scrollbar.limit`
limit: { x: number, y: number, },
};
Thank you.
Clapat Support
https://www.clapat.com/
Review Envato Item Support Policy
Thanks, but I found another solution using ScrollMagic.
I wrote this in script.js to add a css class to the header :
And added "headerScene.refresh()" in this condition to make the smooth scroll work with this class change :
Thank you for your help.
Ok Quentin, good work on this.
Thank you.
Clapat Support
https://www.clapat.com/
Review Envato Item Support Policy