Created
June 28, 2018 02:48
-
-
Save georgiawang5332/5c3f8c790c761295bdf11a4f4f4978b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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