2
我正在學習如何使用Spin.js,以便在加載網頁時顯示加載指示器(微調器)。如何使用spin.js顯示頁面加載指示器
我得到它的工作,但我不知道我是否在正確的頁面生命週期中調用spin/stop。是否可以在$(window).ready
之前顯示微調器?
<script type="text/javascript">
var spinner;
$(window).ready(function loadingAnimation() {
var opts = {
lines: 13, // The number of lines to draw
length: 7, // The length of each line
width: 4, // The line thickness
radius: 10, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
color: '#000', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: 'auto', // Top position relative to parent in px
left: 'auto' // Left position relative to parent in px
};
var target = $("body")[0];
spinner = new Spinner(opts).spin(target);
});
window.onload = function() {
spinner.stop();
};
對於工作示例,請參閱http://sgratrace.appspot.com/industry.html
你能告訴我如何獲得Rats.js文件,並且我正在嘗試在MVC中做同樣的事情,你是否也可以讓我知道是否需要做其他事情來添加事物。 – Shivam657 2014-12-19 07:46:09
嗨Shivam,你可以在這裏得到它https://github.com/seahrh/sgratrace/blob/master/war/js/rats.js – ruhong 2015-01-11 08:00:14
@ oneleggednule-你有任何解決方案的MVC,我正在研究MVC5和尋找同樣的解決方案。謝謝。 – Shivam657 2015-01-12 18:57:45