Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
16
css
body { background-color: #FEC800; overflow: hidden; text-align: center; } body, html { height: 100%; width: 100%; margin: 0; padding: 0; } #animationWindow, .sliderSVG { position:absolute; left:0; width: 100%; height: 100%; } #popWindow{ pointer-events:none; } .handleDisplay{ user-select:none; pointer-events:none; } text{ font-size:1.5em; text-anchor:middle; width:100%; font-family:"Ubuntu", sans-serif; font-weight:700; fill:#FFF; } #animationWindow, .sliderSVG { position:absolute; left:0; width:100%; height:100%; } .swatch rect{ cursor:pointer; }
JavaScript
var animData = { wrapper: document.querySelector('#animationWindow'), animType: 'svg', loop: true, prerender: true, autoplay: false, path: '//www.jq22.com/gxwj/responsive_lego_003.json' }; var anim = bodymovin.loadAnimation(animData); anim.setSpeed(1); var snapValue, maxX, tl, handle = document.querySelector('.handle'), numStages, handleTextArray = [1,2,4,6,8,10,12,14,16], dimpleArray = [ [{x:416, y:310}], [{x:418, y:280}], [{x:413, y:305}, {x:437, y:281}], [{x:425, y:314}, {x:452, y:293}], [{x:438, y:321}, {x:464, y:302}], [{x:451, y:332}, {x:478, y:312}], [{x:462, y:339}, {x:489, y:319}], [{x:474, y:349}, {x:499, y:328}], [{x:486, y:358}, {x:512, y:338}] ], brickColorArray = [ {side:'#DE002E', top:'#E42F3F', front:'#CD0022'}, {side:'#F65F23', top:'#F99859', front:'#EC4518'}, {side:'#9AC43D', top:'#A1D039', front:'#749426'}, {side:'#5CAFCD', top:'#73D6F2', front:'#3787A8'}, {side:'#F7E143', top:'#F8E944', front:'#E3B537'}, {side:'#DE519B', top:'#F271AC', front:'#B1005E'} ], handleText = document.querySelector('.handleText'), pop = document.querySelector('#pop'), dimple = document.querySelector('#dimple'), sliderSVG = document.querySelector('.sliderSVG'), allRects = document.querySelectorAll('.swatch rect') TweenMax.set(handle, { x:0 }) TweenMax.set(dimple, { transformOrigin:'50% 50%' }) anim.addEventListener("DOMLoaded", onLoaded); function dragUpdate(){ var posX = handle._gsTransform.x; var posY = handle._gsTransform.y; var id = (posX/maxX)*numStages; handleText.textContent = handleTextArray[id]; var dragPercent = (posX/maxX); var playhead = dragPercent * (tl.duration()-(2)); TweenMax.to(tl,1, { time:(playhead <= 0 ) ? 0 : playhead, ease:(playhead <= 0 ) ? Elastic.easeOut.config(0.1,1) : Elastic.easeOut.config(1,0.7) //ease:Elastic.easeOut.config(1.7,0.7) }) TweenMax.fromTo('#animationWindow', 0.6, { //rotation:3 },{ rotation:0, ease:Elastic.easeOut.config(0.5, 0.6) }) var c = pop.cloneNode(true); sliderSVG.appendChild(c); TweenMax.fromTo(c, 2, { x:posX, attr:{ r:20 }, alpha:1 //y:posY },{ x:posX, attr:{ r:60 }, alpha:0, //stroke:'#E3000B', onComplete:removePop, onCompleteParams:[c], ease:Expo.easeOut //y:posY }) var d, dtl = new TimelineMax(); for(var i = 0; i < dimpleArray[id].length; i++){ d = dimple.cloneNode(true); sliderSVG.appendChild(d); var tween = TweenMax.fromTo(d, 1.7, { x:dimpleArray[id][i].x, y:dimpleArray[id][i].y-6, attr:{ r:10 }, alpha:1, skewX:50, rotation:-20 },{ attr:{ r:35 }, alpha:0, //stroke:'#E3000B', onComplete:removePop, onCompleteParams:[d], ease:Expo.easeOut //y:posY }) dtl.add(tween, i/20) } } function removePop(c){ sliderSVG.removeChild(c) } function onLoaded(e){ var mainGroup = document.querySelectorAll('svg')[0].querySelectorAll('g')[0]; mainGroup.setAttribute('filter', 'url(#edgeClean)'); TweenMax.staggerFrom(allRects, 2, { cycle:{ alpha:function(i, t){ t.setAttribute('fill-data', i); t.onclick = changeColour; //add colours as the hover title nodes var titleTag = document.createElementNS("http://www.w3.org/2000/svg", 'title'); var desc = document.createTextNode(t.getAttribute('fill')); titleTag.appendChild(desc); t.appendChild(titleTag) return 0; } } },0.1) //console.log(mainGroup) tl = new TimelineMax({paused:true}); tl.to({frame:0},18, { frame:anim.totalFrames-1, ease:Linear.easeNone, onUpdate:function(){ anim.goToAndStop(Math.round(this.target.frame), true); } }) handle = document.querySelector(".handle"), maxX = 400, numStages = 8, snapValue = maxX/numStages; Draggable.create(handle, { type:'x', cursor:'pointer', //throwProps:true, //snap:getSnap(), liveSnap:function(endValue){ return Math.round(endValue / snapValue) * snapValue; }, bounds:{minX:0, maxX:maxX}, onDrag:dragUpdate }) dragUpdate(); //console.log(anim.totalFrames * Math.abs(anim.frameModifier)) //console.log(Math.round(anim.totalFrames/ anim.frameRate)) changeColour({currentTarget:allRects[3]}) } function changeColour(e){ var id = parseInt(e.currentTarget.getAttribute('fill-data')); TweenMax.set('#dimple', { stroke:brickColorArray[id].front }) TweenMax.set('svg:first-child g path', { fill:brickColorArray[id].front }) //console.log(parseInt(e.currentTarget.getAttribute('fill-data'))) TweenMax.set('.sideFace path', { fill:brickColorArray[id].side }) TweenMax.set('.topFace path', { fill:brickColorArray[id].top }) TweenMax.set('.frontFace path', { fill:brickColorArray[id].front }) TweenMax.staggerTo(allRects, 0.15, { cycle:{ scaleY:function(i, target){ return (e.currentTarget == target) ? 1.3 : 1 } }, transformOrigin:'50% 100%' },0) } function getSnap() { var t = function(endValue) { return Math.round(endValue / snapValue) * snapValue; } return t; }
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>响应式乐高-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号