Home > Web Front-end > JS Tutorial > An effect style plug-in for image and video buffering created based on jquery_jquery

An effect style plug-in for image and video buffering created based on jquery_jquery

WBOY
Release: 2016-05-16 17:50:24
Original
1022 people have browsed it
Copy code The code is as follows:

(function($) {
$.fn.scrollWait = function(options) {
var ops = $.extend({}, $.fn.scrollWait.defaults, options);
var opts = $.meta ? $.extend({}, ops, $( this).data()) : ops;
/**
* Show location
*/
var win = $(window);
var winheight = win.height();
var winwidth = win.width();
var dsize = opts.size;
var top = opts.top;
var left = opts.left;
var dtop = !top && top != "" && typeof top != "undefined" && top != 0
? (winheight - dsize) / 2
: top;
var dleft = !left && left != "" && typeof left != " undefined"
&& left != 0 ? (winwidth - dsize) / 2 : left;
// Number of origins
var num = opts.num;
// Diameter of origin
var R = dsize / num * opts.areaWeight;
// Radius
var r = 1 / 2 * R;
// Outer circle diameter
var outerR = 1 / 2 * dsize;
//Inner circle diameter
var innerR = outerR - R;
//Traverse and add origin object
for (var i = 0; i < num; i ) {
$('body' ).append($("
i "">
"));
}
// The actual coordinate is 0, 0
var i = 0;
var innerArray = new Array(num);
/**
* Calculate the center coordinates of the point on the inner circle
*/
for (var j = 0; j < innerArray.length; j ) {
var x, y;
var ang = i * 360 / num;
if (0 <= ang && ang <= 90) {
x = outerR * Math.sin (ang / 180 * Math.PI) outerR;
y = outerR - outerR * Math.cos(ang / 180 * Math.PI);
}
if (90 < ang && ang < = 180) {
x = outerR * Math.cos((ang - 90) / 180 * Math.PI) outerR;
y = outerR * Math.sin((ang - 90) / 180 * Math. PI) outerR;
}
if (180 < ang && ang <= 270) {
x = outerR - outerR * Math.sin((ang - 180) / 180 * Math.PI) ;
y = outerR * Math.cos((ang - 180) / 180 * Math.PI) outerR;
}
if (270 < ang && ang <= 360) {
x = outerR - outerR * Math.cos((ang - 270) / 180 * Math.PI);
y = outerR - outerR * Math.sin((ang - 270) / 180 * Math.PI);
}
innerArray[j] = new Array(dtop y - r, dleft x - r);
i ;
}
/**
* Draw a circle
*/
$( ".innerCircle").each(function() {
$(this).css({
'width' : R "px",
'height' : R "px",
'border-top-left-radius' : r "px",
'border-top-right-radius' : r "px",
'border-bottom-left-radius' : r "px" ,
'border-bottom-right-radius' : r "px"
});
});
for (var i = 0; i < num; i ) {
$("#innerCircle" i).css({
'top' : innerArray[i][0] "px",
'left' : innerArray[i][1] "px"
});
}
// Find the position of the currently paused circle
var val = $("#current").val();
if (val == undefined || val == "") {
$("body").append($(""));
k = 0;
} else {
k = val;
}
var o = new Object();
var timer;
// Start rotating
o.start = function() {
var first;
var g = $("#grade").val();
if (g == undefined || g == "") {
$("body") .append($(""));
first = 1;
} else {
first = g;
}
timer = setInterval(function() {
if (first % 2 == 1) {
$("#innerCircle" k).removeClass("innerCircle")
.addClass("innerCircle- change");
}
if (first % 2 == 0) {
$("#innerCircle" k).removeClass("innerCircle-change")
.addClass("innerCircle" );
}
if (k == (num - 1)) {
k = 0;
console.log(first);
first ;
$("# grade").val(first);
} else {
k ;
}
// Overwrite value
$("#current").val(k);
}, opts.speed);
return this;
}
// Pause
o.stop = function() {
clearInterval(timer);
return this;
}
// End
o.end = function() {
clearInterval(timer);
// Remove all elements
$(".innerCircle,.innerCircle-change, #current,#grade").remove();
}
return o;
}
$.fn.scrollWait.defaults = {
size : 80,
top : null,
left : null,
// Quantity
num: 8,
speed: 200,
// Proportion of dots to the entire area
areaWeight: 5 / 4
};
})(jQuery);

Call method:
Copy codeThe code is as follows:



<머리>
MyHtml.html



href="scroll-wait-jquery-plugin.css">




<본문>



css:
复代码 代码如下:

. innerCircle {
위치: 절대;
배경: #FFFF00;
불투명도: 0.8;
}
.innerCircle-change {
배경: #333;
위치: 절대;
}
 
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template