Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save georgiawang5332/5c3f8c790c761295bdf11a4f4f4978b8 to your computer and use it in GitHub Desktop.
Save georgiawang5332/5c3f8c790c761295bdf11a4f4f4978b8 to your computer and use it in GitHub Desktop.
2018/06/27;10:46am
//html -
<div id="previous-month" class="leftArrow trigger prev"><!-- onclick="preMonth()" -->
<a href="#" class="text-primary">
<i class="fas fa-4x fa-angle-left"></i>
</a>
</div>
<div id="next-month" class="rightArrow trigger next"><!-- onclick="nextMonth()" -->
<a href="#" class="text-primary">
<i class="fas fa-4x fa-angle-right"></i>
</a>
</div>
//js -
//每次獲取的偏移量都是 0 導致的
var leftPos = 0
function preMonth() {
leftPos -= 1000
if (leftPos < 0) leftPos = 0
$('#wrapper').animate({
scrollLeft: leftPos
}, 300);
console.log(leftPos);
}
function nextMonth() {
leftPos += 1000
$('#wrapper').animate({
scrollLeft: leftPos
}, 300)
console.log(leftPos);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment