I have a musicplayer fixed on the bottom of the screen and when I scroll 300px he should start to scroll with the rest of the content. All that works fine at the computer but not on mobile. Its dificult to explain this with my skill in english.
I made a jsfiddle but i cant get it to work there. In my project it works. The musicplayer should start to scroll after i scrolled 300px. If it would work it wouldnt work on mobiles correctly. On mobile it is jerky and dont refresh the position when i am scrolling. only when i stop the scrolling it jumps to the correct position. But it is not smooth like on the computer.
<body>
<div id="content">
//long text see jsfiddle
</div>
<div id="musicplayer">
<div id="control">Musicplayer: play/pause</div>
</div>
</body>
my css:
#content {
width: 2000px;
background-color: black;
color: white;
margin-bottom: 300px;
}
#musicplayer {
position: fixed;
bottom: 0px;
width: 100%;
height: 100px;
background-color: #485670;
z-index: 5;
color: white;
}
my javascript:
$(window).scroll(function () {
if ($(window).scrollTop() >300) {
$('#musicplayer').css('bottom', $(window).scrollTop()-300);
}
else if($(window).scrollTop() < 300) {
$('#msuciplayer').css('bottom', 0)
}
});
Edit: I got an idea. but at the moment i dont have time to try it out anymore. I try it tomorrow.