Rx实现拖拽小球重叠覆盖率实时计算效果代码
代码语言:html
所属分类:拖放
代码描述:Rx实现拖拽小球重叠覆盖率实时计算效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { padding-top: 15px; background-color: #64bbda; font-family: 'Quicksand', Arial; display: flex; justify-content: center; user-select: none; cursor: default; overflow: hidden; } .circle { top: calc(50% - 75px); border-radius: 50%; height: 150px; width: 150px; position: absolute; } .circle:hover { cursor: grab; cursor: -webkit-grab; cursor: -moz-grab; } #output { border-radius: 5px; background-color: rgba(0, 0, 0, 0.6); color: white; font-size: 1.5em; padding: 4px 8px 4px 8px; z-index: 0; } #one { border: 1px solid rgba(0, 0, 0, 0.1); background-color: #9fcedf; top: calc(60% - 75px); left: calc(25% - 75px); box-shadow: inset -9px 0px 30px 0 rgba(255, 250, 193, 0), 5px 5px 20px 5px rgba(255, 250, 193, 0); z-index: 1; } #two { background-color: #fff36e; top: calc(40% - 75px); left: calc(50% - 75px); box-shadow: 0 0 20px 5px #fffac1; z-index: -1; } @keyframes totality { from { box-shadow: 0 0 20px 5px #fffac1; } to { box-shadow: 0 0 75px 20px #ffffff; } } #two.totality { box-shadow: 0 0 75px 20px #ffffff; animation-name: totality; animation-duration: 1s; } </style> </head> <body> <div id="output">Coverage: 0%</div> <div class="circle draggable" id="two"> </div> <div class="circle draggable" id="one"> </div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/Rx.5.4.3.js"></script> <script > const draggables = document.querySelectorAll('.draggable'); const one = document.getElementById('one'); const two = document.getElementById('two'); const output = document.getElementById('output'); const scale = (low, high, ratio, power = 1) => low + (high - low) * Math.pow(ratio, power); const descale = (value, low, range) => (value - low) / ran.........完整代码请登录后点击上方下载按钮下载查看
网友评论0