Draggable实现空调温度拖拽调节效果代码
代码语言:html
所属分类:拖放
代码描述:Draggable实现空调温度拖拽调节效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Baloo+Paaji+2&display=swap'> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Unica+One&display=swap'> <style> * { border: 0; box-sizing: border-box; margin: 0; padding: 0; } :root { --bg: #fff; font-size: calc(16px + (24 - 16) * (100vw - 320px) / (1280 - 320)); } body { background: var(--bg); display: grid; place-items: center; font: 1em/1.5 sans-serif; height: 100vh; overflow: hidden; } .temp { --f: 0; --angle: 0; --hue: 240; background-image: radial-gradient( 100% 100% at 50% 50%, hsl(var(--hue),90%,17%) 3.55em, hsla(var(--hue),90%,17%,0) 3.6em ), radial-gradient( 100% 100% at 50% 50%, hsl(var(--hue),90%,10%), hsl(var(--hue),90%,23%) 4.65em, hsl(var(--hue),90%,55%) 4.85em 4.9em, #17181c 5.1em 6.85em, #17181c00 6.9em ), radial-gradient(100% 100% at 50% 0,#f1f2f4,#8f95a3); border-radius: 50%; box-shadow: 0 -0.25em 1.5em 0.5em #0004; display: flex; flex-direction: column; line-height: 1; position: relative; padding: 1em; text-align: center; width: 15em; height: 15em; } .temp:after, .temp__dial, .temp__comet, .temp__fizz { position: absolute; } .temp:after, .temp__comet, .temp__dial { border-radius: inherit; } .temp:after, .temp__dial { top: 0; left: 0; width: 100%; height: 100%; } .temp:after { background: radial-gradient(100% 100% at 67% 17%,#fff3,#fff0 6em); content: ""; display: block; z-index: 2; } .temp__logo { font-family: "Baloo Paaji 2", sans-serif; color: #abafba; letter-spacing: -0.1em; margin-bottom: 3.75em; text-transform: lowercase; transform: scaleY(1.1); } .temp__comet { background: radial-gradient( 100% 100% at 50% 50%, hsl(var(--hue),90%,10%), hsl(var(--hue),90%,20%) 3.25em, hsl(var(--hue),90%,17%) 3.3em 3.35em, hsla(var(--hue),90%,17%,0) 3.4em ), conic-gradient(#fff0,#fff calc(1deg * var(--angle)),#fff0 calc(1deg * var(--angle))); top: calc(50% - 3.5em); left: calc(50% - 3.5em); width: 7em; height: 7em; } .temp__fizz { display: block; top: calc(50% - 3.3em); left: calc(50% - 3.3em); width: 6.6em; height: 6.6em; } .temp__label, .temp__value { color: #fff; font-family: "Unica One", monospace; position: relative; z-index: 1; } .temp__label { font-size: 0.6em; letter-spacing: 0.5em; text-transform: uppercase; transform: translateX(0.25em) scaleY(0.9); } .temp__value { font-size: 3.5em; } .temp__dial { cursor: grab; z-index: 3; } .temp__dial:active { cursor: grabbing; } /* Dark theme */ @media (prefers-color-scheme: dark) { :root { --bg: #2e3138; } } </style> </head> <body > <div class="temp"> <div class="temp__logo">Nest</div> <div class="temp__comet"></div> <canvas class="temp__fizz"></canvas> <div class="temp__label">Temp</div> <div class="temp__value">0</div> <div class="temp__dial"></div> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.5.2.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Draggable3.min.js"></script> <script > document.addEventListener("DOMContentLoaded",function(){ const thermostat = new Thermostat(".temp"); }); class Thermostat { constructor(el) { this.el = document.querySelector(el); this.temp = 0; this.tempMin = 0; this.tempMax = 100; this.fizz = null; this.fizzParticleCount = 600; this.fizzParticles = []; this.fc = null; this.fW = 240; this.fH = 240; this.fS = window.devicePixelRatio; this.init(); } init() { window.addEventListener("keydown",this.kbdEvent.bind(this)); if (this.el) { this.fizz = this.el.querySelector(".temp__fizz&quo.........完整代码请登录后点击上方下载按钮下载查看
网友评论0