WordPress Elementor sticky image scrolling free template.
Features
🔸Fully customizable
🔸Fully customizable
🔸Responsive
🔸Code
Tutorial link:
☑️Support me on Patreon
☑️Download link Click here
code
<script src = "https://code.jquery.com/jquery-3.6.0.min.js">
</script>
<script>
$(window).scroll(function(e) {
var $h = screen.height;
var $offset = -100;
var $firstOffset = 100;
if (window.matchMedia('(min-width: 600px)').matches){
for (let i = 0; i < 2; i++) {
var $el1 = $('.img' + (i + 1));
if (i == 0) {
var isPositionFixed = ($el1.css('position') == 'fixed');
if ($(this).scrollTop() > ($h * i) + $firstOffset && !isPositionFixed) {
$el1.css({'position': 'fixed',
'top': '25px'});
}
if ($(this).scrollTop() < ($h * i) + $firstOffset && isPositionFixed) {
$el1.css({'position': 'static','top': '25px'});
}
} else {
var isPositionFixed = ($el1.css('position') == 'fixed');
if ($(this).scrollTop() > ($h * i) + $offset && !isPositionFixed) {
$el1.css({'position': 'fixed','top': '25px'});
}
if ($(this).scrollTop() < ($h * i) + $offset && isPositionFixed) {
$el1.css({'position': 'static','top': '25px'});
}
}
}
}
});
</script>
</script>
<script>
$(window).scroll(function(e) {
var $h = screen.height;
var $offset = -100;
var $firstOffset = 100;
if (window.matchMedia('(min-width: 600px)').matches){
for (let i = 0; i < 2; i++) {
var $el1 = $('.img' + (i + 1));
if (i == 0) {
var isPositionFixed = ($el1.css('position') == 'fixed');
if ($(this).scrollTop() > ($h * i) + $firstOffset && !isPositionFixed) {
$el1.css({'position': 'fixed',
'top': '25px'});
}
if ($(this).scrollTop() < ($h * i) + $firstOffset && isPositionFixed) {
$el1.css({'position': 'static','top': '25px'});
}
} else {
var isPositionFixed = ($el1.css('position') == 'fixed');
if ($(this).scrollTop() > ($h * i) + $offset && !isPositionFixed) {
$el1.css({'position': 'fixed','top': '25px'});
}
if ($(this).scrollTop() < ($h * i) + $offset && isPositionFixed) {
$el1.css({'position': 'static','top': '25px'});
}
}
}
}
});
</script>
Comments
Post a Comment