Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
{{currentTemperature | round}}
{{el}}
|
css
body { margin: 0; color: white; font-family: Arial, Helvetica, sans-serif; } .main-container { display: grid; grid-template-columns: 1fr; grid-template-rows: 3fr 1fr; height: 100vh; overflow-x: hidden; } .upper-container { position: relative; background: linear-gradient(to bottom right, #5564C2, #3A2E8D); } .temperature-text { position: absolute; bottom: 150px; user-select: none; font-size: 100px; width: 100%; text-align: center; } .temperature-graduation { left: calc(50% - 150px); position: absolute; bottom: 25px; user-select: none; } .temperature-element { text-align: center; display: inline-block; width: 40px; margin: 0 10px 0 10px; opacity: 0.7; } .temperature-element-line { font-size: 7px; } .lower-container { background-color: #12132C; } .slider-container { width: 150px; height: 80px; margin-top: -30px; margin-left: calc(50% - 187px); position: relative; } .slider-button { position: absolute; left: 42px; top: 5px; width: 50px; height: 50px; border-radius: 50%; background-color: #2724A2; cursor: grab; cursor: -webkit-grab; cursor: -moz-grab; } .grabbing { cursor: grabbing; cursor: -webkit-grabbing; cursor: -moz-grabbing; } .slider-icon { margin-top: 16px; margin-left: 21px; color: white; }
JavaScript
const sliderMinX = 0 const sliderMaxX = 240 const coldGradient = {start: '#5564C2', end: '#3A2E8D'} const hotGradient = {start:'#F0AE4B', end: '#9B4D1B'} new Vue({ el: '#app', data: { dragging: false, initialMouseX: 0, sliderX: 0, initialSliderX: 0, temperatureGrades: [10, 15, 20, 25, 30], gradientStart: coldGradient.start, gradientEnd: coldGradient.end }, filters: { round (num) { return Math.round(num) } }, methods: { startDrag (e) { this.dragging = true this.initialMouseX = e.pageX this.initialSliderX = this.sliderX }, stopDrag () { this.dragging = false }, mouseMoving (e) { if(this.dragging) { const dragAmount = e.pageX - this.initialMouseX const targetX = this.initialSliderX + dragAmount // keep slider inside limits this.sliderX = Math.max(Math.min(targetX, sliderMaxX), sliderMinX) // set bg color let targetGradient = coldGradient if (this.currentTemperature >= 25) { targetGradient = hotGradient } if(this.gradientStart !== targetGradient.start) { // gradient changed TweenLite.to(this, 0.7, { 'gradientStart': targetGradient.start, 'gradientEnd': targetGradient.end }) } } }, tempElementStyle (tempNumber) { const nearDistance = 3 const liftDistance = 12 // lifts up the element when the current temperature is near it const diff = Math.abs(this.currentTemperature - tempNumber) const distY = (diff/nearDistance) - 1 // constrain the distance so that the element doesn't go to the bottom const elementY = Math.min(distY*liftDistance, 0) return `transform: translate3d(0, ${elementY}px, 0)` } }, computed: { currentTemperature () { const tempRangeStart = 10 const tempRange = 20 // from 10 - 30 return (this.sliderX / sliderMaxX * tempRange ) + tempRangeStart }, sliderStyle () { return `transform: translate3d(${this.sliderX}px,0,0)` }, bgStyle () { return `background: linear-gradient(to bottom right, ${this.gradientStart}, ${this.gradientEnd});` } } })
粒子
时间
文字
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号