insulae
December 3, 2018, 11:23pm
1
Hi! I want to do a scroll indicator.
the simplest example is this:
https://www.w3schools.com/howto/howto_js_scroll_indicator.asp
this example use this function:
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
}
but the event is not detected. I tried use jquery:
$("#target").scroll(function(){
alert("ok");
})
on a div, on the body and it does not work.
Is there something in Framework7 that “blocks” the event? What I can do?
Thank you! Framework7 is impressive every day I like it more!
You should attach scroll handler to current’s page `page-content’, e.g.:
$('.page-content').on('scroll', function () {
var scrollTop = this.scrollTop;
})
2 Likes
insulae
December 4, 2018, 11:52am
3
YOU ARE THE BEST!! I should have tried that, my mistake.
nolimits4web is incredible what you are doing, I take this opportunity to thank you directly.
I’ve been learning your framework for a week and I have nothing but praise.
thank you! and I promise to help in some way this community soon.
2 Likes
How to make this work using https://framework7.io/vue ?
I have relative problem here getting the scroll position Infinite Scroll get current scroll position
methods: {
contentScrolled(position) {
console.log('Content scrolled to: ' + position);
}
},
mounted() {
this.$f7.$('.page-content').on('scroll', (e) => {
this.contentScrolled(e.srcElement.scrollTop);
})
}
https://jsfiddle.net/Silver775/g0amp245/
2 Likes