draggable实现图片亮度对比度饱和度模糊拖拽调节效果代码
代码语言:html
所属分类:拖放
代码描述:draggable实现图片亮度对比度饱和度模糊拖拽调节效果代码
代码标签: draggable 图片 亮度 对比度 饱和度 模糊 拖拽 调节
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> :root { --contrast: 1; --saturate: 0; --blur: 0; --hue: 0deg; --brightness: 1; --img-size: 500px; --controls-width: 480px; --top-offset: -60px; --img-from-top: calc(50vh + (var(--img-size) / 2) + var(--top-offset)); --scroll-height: 60px; --ui-bg: #222; --ui-bg-transparent: #22222200; --buttons-row-height: 100px; } body { background-color: var(--ui-bg); font-family: sans-serif; } *::-webkit-scrollbar { display: none; } * { user-select: none; } body:has(input[name="mode"][value="contrast"]:checked) { .scroller[data-level="1"] { pointer-events: all; } .scroller[data-level="1"] .sizer[data-level="1"]::before { opacity: 1; } [data-mode="contrast"] { color: white; } } body:has(input[name="mode"][value="saturation"]:checked) { .scroller[data-level="2"] { pointer-events: all; } .scroller[data-level="2"] .sizer[data-level="2"]::before { opacity: 1; } [data-mode="saturation"] { color: white; } } body:has(input[name="mode"][value="brightness"]:checked) { .scroller[data-level="3"] { pointer-events: all; } .scroller[data-level="3"] .sizer[data-level="3"]::before { opacity: 1; } [data-mode="brightness"] { color: white; } } body:has(input[name="mode"][value="blur"]:checked) { .scroller[data-level="4"] { pointer-events: all; } .scroller[data-level="4"] .sizer[data-level="4"]::before { opacity: 1; } [data-mode="blur"] { color: white; } } body:has(input[name="mode"][value="hue"]:checked) { .scroller[data-level="5"] { pointer-events: all; } .scroller[data-level="5"] .sizer[data-level="5"]::before { opacity: 1; } [data-mode="hue"] { color: white; } } .scroller { height: var(--scroll-height); width: var(--controls-width); overflow-x: scroll; scroll-timeline-axis: x; position: fixed; top: var(--img-from-top); left: 0; right: 0; margin: auto; pointer-events: none; overflow-y: visible; } .scroller-cover { position: absolute; top: calc(var(--img-from-top)); pointer-events: none; height: var(--scroll-height); background-image: linear-gradient(to right, var(--ui-bg), var(--ui-bg-transparent) 30%, var(--ui-bg-transparent) 70%, var(--ui-bg)); z-index: 3; content: ''; left: 0; right: 0; margin: auto; width: var(--controls-width); } .scroller[data-level="1"] { scroll-timeline-name: --scroller-1; } .scroller[data-level="2"] { scroll-timeline-name: --scroller-2; } .scroller[data-level="3"] { scroll-timeline-name: --scroller-3; } .scroller[data-level="4"] { scroll-timeline-name: --scroller-4; } .scroller[data-level="5"] { scroll-timeline-name: --scroller-5; } .sizer { width: 200%; animation-duration: 1ms; animation-direction: alternate; animation-timing-function: linear; overflow: visible; } .scroll-center { content: ''; position: fixed; top: calc(var(--img-from-top) + var(--scroll-height) - 30px); height: 30px; width: 2px; background-color: #FF5D5D; left: -1px; right: 0; margin: auto; display: block; position: absolute; z-index: 9; pointer-events: none; } .sizer::before { content: ''; position: absolute; left: 50%; margin: auto; opacity: 0; background-image: url("https://repo.bfw.wiki/bfwrepo/svg/ticker-6_6.svg"); background-size: 100% 16px; background-repeat: no-repeat; background-position: 0 100%; height: 20px; width: 100%; bottom: 0; pointer-events: none; } .sizer[data-level="1"] { animation-name: contrastAnimation; animation-timeline: --scroller-1; } .sizer[data-level="2"] { animation-name: saturateAnimation; animation-timeline: --scroller-2; } .sizer[data-level="3"] { animation-name: brightnessAnimation; animation-timeline: --scroller-3; } .sizer[data-level="4"] { animation-name: blurAnimation; animation-timeline: --scroller-4; } .sizer[data-level="5"] { animation-name: hueAnimation; animation-timeline: --scroller-5; } #image { width: var(--img-size); height: var(--img-size); position: fixed; pointer-events: none; top: calc(var(--img-from-top) - var(--img-size)); left: 0; right: 0; margin: auto; display: flex; background: var(--ui-bg); align-items: center; justify-content: center; } #image > div { object-fit: contain; width: 100%; height: 100%; margin: auto; overflow: hidden; text-align: center; } #image img { max-width: 100%; max-height: 100%; margin: auto; filter: contrast(var(--contrast)) saturate(var(--saturate)) brightness(var(--brightness)) blur(var(--blur)) hue-rotate(var(--hue)); } .buttons { position: fixed; left: 0; right: 0; margin: auto; top: calc(var(--img-from-top) + var(--scroll-height)); height: var(--buttons-row-height); width: var(--controls-width); z-index: 2; display: flex; justify-content: center; } .buttons > div { flex-basis: 90px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #949494; padding-top: 12px; position: relative; flex-direction: column; } .buttons > div input { appearance: none; opacity: 1; position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: block; width: 100%; height: 100%; z-index: 1; } .buttons > div .icon { width: 48px; height: 48px; background-color: #3B3B3B; border-radius: 50%; margin-bottom: 12px; display: inline-flex; align-items: center; justify-content: center; } .icon svg { width: 24px; } @keyframes contrastAnimation { 0% { --contrast: 0.3; } 50% { --contrast: 1; } 100% { --contrast: 2; } } @keyframes saturateAnimation { 0% { --saturate: 0; } 50% { --saturate: 1; } 100% { --saturate: 10; } } @keyframes blurAnimation { 0% { --blur: 0px; } 100% { --blur: 30px; } } @keyframes hueAnimation { 0% { --hue: 0deg; } 100% { --hue: 360deg; } } @keyframes brightnessAnimation { 0% { --brightness: 0; } 50% { --brightness: 1; } 100% { --brightness: 2; } } /* @property --contrast { syntax: "<number>"; inherits: false; initial-value: 0; } @property --saturate { syntax: "<number>"; inherits: false; initial-value: 0; } */ </style> </head> <body > <div class="scroller-cover"></div> <div class="scroll-center"></div> <div class="scroller" data-level="1"> <div class="sizer" data-level="1"> <div class="scroller" data-level="2"> <div class="sizer" data-level="2"> <div class="scroller" data-level="3"> <div class="sizer" data-level="3"> <div class="scroller" data-level="4" data-no-initial-scroll> <div class="sizer" data-level="4"> <div class="scroller" data-level="5" data-no-initial-scroll> <div class="sizer" data-level="5"> <div id="image"> <div> <!-- Change this to any image --> <img src="//repo.bfw.wiki/bfwrepo/image/65949b9c3bacb.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" /> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> </div> <div class="buttons"> <div data-mode="contrast"> <input type="radio" name="mode" value="contrast" checked/> <div class="icon"> <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M29.37 11.84C29.1015 10.97 28.7464 10.1291 28.31 9.33001C27.6646 8.14402 26.8531 7.05635 25.9 6.10001C23.942 4.14221 21.4474 2.80899 18.7317 2.26891C16.016 1.72883 13.2012 2.00616 10.6431 3.06583C8.085 4.1255 5.89858 5.91991 4.3603 8.22217C2.82203 10.5244 2.00098 13.2311 2.00098 16C2.00098 18.7689 2.82203 21.4756 4.3603 23.7778C5.89858 26.0801 8.085 27.8745 10.6431 28.9342C13.2012 29.9939 16.016 30.2712 18.7317 29.7311C21.4474 29.191 23.942 27.8578 25.9 25.9C26.8531 24.9437 27.6646 23.856 28.31 22.67C28.7464.........完整代码请登录后点击上方下载按钮下载查看
网友评论0