Draggables手机壳颜色拖拽颜色更换效果代码

代码语言:html

所属分类:拖放

代码描述:Draggables手机壳颜色拖拽颜色更换效果代码

代码标签: 颜色 拖拽 颜色 更换 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
<style>
* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
}

color-sidebar {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  padding: 10px;
  z-index: 2;
  touch-action: none;
}

color-picker {
  display: block;
  position: relative;
}

color-item,
color-draggable {
  display: block;
  border-radius: 50%;
  visibility: hidden;
  opacity: 0;
  box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.26);
  cursor: move;
  cursor: -webkit-grab;
  cursor: grab;
}

color-item {
  position: relative;
  margin: 10px 10px 0 10px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
}

color-draggable {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  position: absolute;
}

color-draggable.dragging {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

.phone-content {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 31px;
  background: linear-gradient(white, #f2f2f2);
}

phone-container {
  display: block;
  position: relative;
  width: 56.3555347092vmin;
  padding-top: 159.7003745318%;
  visibility: hidden;
  opacity: 0;
}

#phone-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible !important;
}

#phone-mask-path {
  fill: #fff;
  stroke: #fff;
  stroke-width: 4;
}

#phone-outline {
  fill: white;
  stroke: white;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  stroke: rgba(0, 0, 0, 0.2);
}
</style>



</head>

<body >
  <section class="phone-content">
  <phone-container>      
    <svg id="phone-svg" viewBox="0 0 1335 2132">
      
      <filter id="drop-shadow" x="-100%" y="-100%" width="300%" height="300%">
        <feGaussianBlur id="shadow-blur" in="SourceAlpha" stdDeviation="50"/>
        <feOffset dx="0" dy="0" result="offsetblur"/>
        <feFlood id="shadow-color" flood-color="#fff"/>
        <feComposite in2="offsetblur" operator="in"/>
        <feMerge>
          <feMergeNode/>
          <feMergeNode in="SourceGraphic"/>
        </feMerge>
      </filter>
      
      <mask id="phone-mask" maskUnits="userSpaceOnUse">
        <path id="phone-mask-path" d="M390.001733,1932.5 C390.001733,1932.5 565.999988,1931.5 586.05712,1931.5 C606.114252,1931.5 617.023773,1915.5 620.828278,1915.5 C660.021292,1915.5 735.169897,1915.5 737.998019,1915.5 C740.826141,1915.5 746.051941,1931.5 778.812117,1931.5 C811.572292,1931.5 971.998267,1932.5 971.998267,1932.5 C1043.24228,1932.5 1106,1869.76062 1106,1797.49805 L1106,338.501954 C1106,255.587048 1040.06342,200.5 978.998267,200.5 L903.563583,200.5 C877.936549,200.5 860.246162,215.5 860.246162,215.5 L797.920589,215.5 C797.920589,215.5 776.386439,200.5 760.492377,200.5 C744.598316,200.5 379.001733,200.5 379.001733,200.5 C307.757721,200.5 250,260.459622 251,340.704544 L251,604.642372 L258,630.93573 L258,745.743147 L251,769.688698 L251,865.914447 L258,887.652675 L258,1128.96869 L251,1148.60567 L252,1791.49805 C252,1878.48584 318.756326,1932.5 390.001733,1932.5 Z" />
      </mask>
                          
      <path id="phone-outline" filter="url(#drop-shadow)" d="M390.001733,1932.5 C390.001733,1932.5 565.999988,1931.5 586.05712,1931.5 C606.114252,1931.5 617.023773,1915.5 620.828278,1915.5 C660.021292,1915.5 735.169897,1915.5 737.998019,1915.5 C740.826141,1915.5 746.051941,1931.5 778.812117,1931.5 C811.572292,1931.5 971.998267,1932.5 971.998267,1932.5 C1043.24228,1932.5 1106,1869.76062 1106,1797.49805 L1106,338.501954 C1106,255.587048 1040.06342,200.5 978.998267,200.5 L903.563583,200.5 C877.936549,200.5 860.246162,215.5 860.246162,215.5 L797.920589,215.5 C797.920589,215.5 776.386439,200.5 760.492377,200.5 C744.598316,200.5 379.001733,200.5 379.001733,200.5 C307.757721,200.5 250,260.459622 251,340.704544 L251,604.642372 L258,630.93573 L258,745.743147 L251,769.688698 L251,865.914447 L258,887.652675 L258,1128.96869 L251,1148.60567 L252,1791.49805 C252,1878.48584 318.756326,1932.5 390.001733,1932.5 Z" />
      
      <g>
        <rect id="background" fill="#b8c2de" width="100%" height="100%" mask="url(#phone-mask)" /> 
        <g id="ripple-layer" mask="url(#phone-mask)"></g>
      </g>      
      <image x="1" y="1" width="1333px" height="2130px" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/106114/phone.png?v=1" /> 
    </svg>   
  </phone-container>
</section>    
  
<section class="color-content">
  <color-sidebar>      
    <color-picker></color-picker>    
  </color-sidebar>   
</section>

  <script>
      (function() {
  
  "use strict";
  
  function getContour(bezier, tolerance) {
    
    if (tolerance == null) {
      tolerance = 1;
    }
    
    var size  = bezier.length;
    var first = bezier[0];
    var last  = bezier[size - 1];    
    var prev  = first;
    
    var x0 = first.x;
    var y0 = first.y;

    var p.........完整代码请登录后点击上方下载按钮下载查看

网友评论0