testt
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Auto Scroll with jQuery</title>
<link rel="stylesheet" href="cours.css">
</head>
<body>
<div id="q1">((BEGIN)) Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me ((END)) Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me ((END)) Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me Watch me ((END))
<canvas>
<img src="bg.jpg" />
<script type="text/javascript">
var
canvas = document.querySelector('canvas'),
ctx = canvas.getContext('2d'),
beginPath = false;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.addEventListener('mousemove', function (event) {
var x = event.clientX, y = event.clientY;
if (beginPath) {
ctx.lineTo(x, y);
ctx.stroke();
} else {
ctx.beginPath();
ctx.moveTo(x, y);
beginPath = true;
}
}, false);
</script>
</div>
</canvas>
<script data-cfasync="false" src="jquery.js"></script>
<script data-cfasync="false" src="app.js"></script>
</body>
</html>
CSS
#q1 {overflow-y: scroll; width:100%;}
JavaScript
function animatethis(targetElement, speed) {
var scrollWidth = $(targetElement).get(0).scrollWidth;
var clientWidth = $(targetElement).get(0).clientWidth;
$(targetElement).animate({ scrollLeft: scrollWidth - clientWidth },
{
duration: speed,
complete: function () {
targetElement.animate({ scrollLeft: 0 },
{
duration: speed,
complete: function () {
animatethis(targetElement, speed);
}
});
}
});
};
animatethis($('#q1'), 5000);