商品 | 价格 | 图片 |
---|
<script></script>
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 }
/*
* 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) 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) 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 ) 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) return c*(7.5625*t*t) + b;
} else if (t return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
} else if (t 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 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!
The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.
Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.
Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.
Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.
The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.
Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.
JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.
I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing
AI-powered app for creating realistic nude photos
Online AI tool for removing clothes from photos.
Undress images for free
AI clothes remover
Generate AI Hentai for free.
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
Useful JavaScript development tools
Integrate Eclipse with SAP NetWeaver application server.
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
The most popular open source editor