


Product removal special effects production: timer, countdown, dithering special effects code
剩余:
0
0
:
0
0
:
0
0
iphone6s
抢购价:¥ 6000
剩余:
0
0
:
0
0
:
0
0
iMac
抢购价:¥ 19999
剩余:
0
0
:
0
0
:
0
0
ipod
抢购价:¥ 1000
剩余:
0
0
:
0
0
:
0
0
iWatch
抢购价:¥ 2000
商品 | 价格 | 图片 |
---|
var liElements = document.querySelectorAll('li');
var tbodyElements = document.querySelector('.table tbody');
liElements.forEach(function (li) {
soldOut(li);
});
function soldOut(li) {
/*
* 以其中给一个li来做逻辑处理
* */
var buttonElement = li.querySelector('button');
var text1Element = li.querySelector('.text1');
var maskElement = li.querySelector('.mask');
var soldOutElement = li.querySelector('.sold_out');
var timeSpanElement = li.querySelectorAll('.time span');
var goodsName = li.querySelector('.goods_name').innerHTML;
var goodsPrice = li.querySelector('.goods_price').innerHTML;
var goodsImg = li.querySelector('.img').src;
/*
* 点击按钮获取倒计时的时间
* */
buttonElement.onclick = function() {
var seconds = parseInt(text1Element.value);
/*
* 把seconds变成时分秒的格式,并计算倒计时
* */
var timer = setInterval(function () {
seconds--;
if (seconds >= 0) {
var timeArr = seconds2HMS(seconds).split('');
timeArr.forEach(function (item, index) {
timeSpanElement[index].innerHTML = item;
});
} else {
//时间到了
clearInterval(timer);
timeOver();
add2List();
}
}, 1000);
};
function timeOver() {
maskElement.style.display = 'block';
// maskElement.style.opacity = '0.5';
animation(maskElement, {
opacity: 0.5
}, 500);
soldOutElement.style.display = 'block';
animation(soldOutElement, {
width: 198,
height: 198,
left: 61,
top: 76,
opacity: 1
}, 500, 'bounceOut');
setTimeout(function () {
shake(li, 'left', 20, 2);
}, 200);
}
/*
* 添加当前的商品信息到表格列表中
* */
function add2List() {
tbodyElements.innerHTML += '
// animation(trElements[trElements.length - 1], {
// opacity: 1
// 100); }, 100);
}, 1000);
}
var H = addZero(parseInt(seconds / 3600));
var M = addZero(parseInt(seconds % 3600 / 60));
var S = addZero(parseInt (seconds % 60));
}
return (v < 10 ? '0' : '') + v;
}
/*
* Tremble!
function shake(element, attr, range, step) {
/*
* */
var OriginValue = getCSS (Element, Attr);
* Represents+or-
**/
Var Flag = TRUE;
Var Timer = Setinterval (function () () {
if (flag) {
element.style[ Attr] = Originvalue + Range + 'PX';
Range- = STEP;
## If (Range & LT; = 0) {
Element.style [ATTR] = originValue + 'px';
= originValue + 'px'; #}
function getCss(element, attr) {
return parseFloat(element.currentStyle ? element.currentStyle[attr] : getComputedStyle(element)[attr]); ;/script>
if (ele. timer) {
return;
}
var d = duration || 1000;
var obj = {};
for (var attr in attrs) {
obj[attr].b = parseFloat(getComputedStyle(ele)[attr]); obj[attr].c = attrs[attr] - obj[attr].b;
}
var fx = fx || 'linear';
var callback = callback || function(){};
var startTime = Date.now();
ele.timer = setInterval(function () {
var t = Date.now() - startTime;
if (t >= d) {
t = d;
}
for (var attr in attrs) {
var value = Tween[fx](t, obj[attr].b, obj[attr].c, d);
if (attr == 'opacity') {
ele.style[attr] = value;
} else {
ele.style[attr] = value + 'px';
}
}
if (t == d) {
clearInterval(ele.timer);
ele.timer = null;
callback();
}
}, 16);
}
var Tween = {
linear: function (t, b, c, d){ //Constant speed
return c*t/d + b;
},
easeIn: function( t, b, c, d){ //Acceleration curve
return c*(t/=d)*t + b; //t/=d t = t / d
},
easeOut: function(t, b, c, d){ //Deceleration curve
return -c *(t/=d)*(t-2) + b;
},
easeBoth: function(t , b, c, d){ //Acceleration and deceleration curve
if ((t/=d/2) < 1) {
return c/2*t*t + b;
}
return -c/2 * ((--t)*(t-2) - 1) + b;
},
easeInStrong: function(t, b, c, d){ //Add Acceleration curve
return c*(t/=d)*t*t*t + b;
},
easeOutStrong: function(t, b, c, d){ //Deceleration curve
return -c * ((t=t/d-1)*t*t*t - 1) + b;
},
easeBothStrong: function(t, b, c, d){ / /Acceleration and deceleration curve
if ((t/=d/2) < 1) {
return c/2*t*t*t*t + b;
}
return -c/2 * ((t-=2)*t*t*t - 2) + b;
},
elasticIn: function(t, b, c, d, a, p){ / /Sinusoidal decay curve (bounce fade-in)
if (t === 0) {
return b; # Return b+c;
) {
a = c;
var s = p/4;
} else {
var s = p/(2*Math.PI) * Math.asin (c/a);
}
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
},
elasticOut: function(t, b, c, d, a, p){ //Sine enhancement curve (bounce out)
if (t === 0) {
return b; p = d*0.3;
}
if (! a || a & lt; math.abs (c) {
a = c;
var s = p / 4;
} else {
var s = p/(2*Math.PI) * Math.asin (c/a);
var s = p/(2*Math.PI) * Math.asin (c/a); Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
},
elasticBoth: function(t, b, c, d, a, p){
if (t === 0) {
Return b;
}
if ((t /= d /2) == 2) {
Return b+c;
# a = c;
var s = p/4;
}
var s = p/(2*Math.PI) * Math.asin (c/a);
}
’ ’ ’ s ’ to ’ t ’s through through out out through out out through out out out through out through over over over''''''‐‐‐‐‐‐‐‐‐‐‐‐‐ ‐‐ ‐ ‐ ‐ ‐ 1) d-s)*(2*Math.PI)/p )) + b;
}
return a*Math.pow(2,-10*(t-=1)) Math.sin ( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
},
backIn: function(t, b, c, d, s){ //Back Reverse acceleration (rewind and fade in)
if (typeof s == 'undefined') {
s = 1.70158;
}
return c*(t/=d)*t*((s+1)*t - s) + b;
},
backOut: function(t, b, c, d, s){
if (typeof s == 'undefined') {
s = 3.70158; //回缩的距离
}
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
},
backBoth: function(t, b, c, d, s){
if (typeof s == 'undefined') {
s = 1.70158;
}
if ((t /= d/2 ) < 1) {
return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
}
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
},
bounceIn: function(t, b, c, d){ //弹球减振(弹球渐出)
return c - Tween['bounceOut'](d-t, 0, c, d) + b;
},
bounceOut: function(t, b, c, d){
if ((t/=d) < (1/2.75)) {
return c*(7.5625*t*t) + b;
} else if (t < (2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
} else if (t < (2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
}
return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
},
bounceBoth: function(t, b, c, d){
if (t < d/2) {
return Tween['bounceIn'](t*2, 0, c, d) * 0.5 + b;
}
return Tween['bounceOut'](t*2-d, 0, c, d) * 0.5 + c*0.5 + b;
}
};
The above is the detailed content of Product removal special effects production: timer, countdown, dithering special effects code. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The word demo is no longer unfamiliar to friends who like to sing, but many users who have never been exposed to it are curious about what demo means. Now let’s take a look at the meaning of the demo brought by the editor. What does demo mean? Answer: Demo tape. 1. The pronunciation of demo is ['deməʊ] in English and ['demoʊ] in America. 2. Demo is the abbreviation of "demonstration", which generally refers to the preliminary effect of listening to a song before it is officially recorded. 3. Demo is used as a noun to refer to sample tapes and sample records. The meaning of verb is trial (especially software), demonstration and demonstration;

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).
