GSAP 和 querySelectorAll 不会在动态添加的字段上触发

如何解决GSAP 和 querySelectorAll 不会在动态添加的字段上触发

我正在尝试使用此代码笔 https://codepen.io/aaroniker/pen/WNxoovJ 中的代码,它在具有类 url-input 的 div 内的输入字段上运行良好,如代码笔所示。但是,当我将它全部放在 id 为 wrapper 的 div 中并添加一个 jquery-clone 函数来复制 div.url-input 时,它成功复制了 HTML,但所有功能都停止为动态添加的字段工作.我在页面的其余部分使用 jQuery,但此代码笔使用纯 javascript。

我怀疑这也是 forEach 循环内的事件侦听器的问题。这是我尝试过的: 而不是第 21 行的 document.querySelectorAll('.url-input').forEach(elem => {,我已经尝试过

document.querySelectorAll('#wrapper').forEach(elem => {

然后是第 23、23、25 和 27 行,我使用了后代选择器,例如elem.querySelector('.url-input .icon') 而不是 elem.querySelector('.icon')

当我尝试上述操作时,即使最初的 url-input 字段也停止工作,并且动态字段也不会触发。我如何将此代码合并到可以动态添加多个 url-input div 的包装器中?

编辑:这里是所有代码,包括克隆过程的脚本。 “模板”标签包含用于 url 输入字段的 HTML 模板的缩小版本,以便于克隆。我还缩小了 CSS 样式,以节省此处的空间。

<html>
<head>
<style>
<!-- From https://codepen.io/aaroniker/pen/WNxoovJ -->
.url-input{--background: #fff; --border-default: #E1E6F9; --border-active: #275EFE; --text-color: #646B8C; --placeholder-color: #BBC1E1; --icon: #275EFE; --close: #646B8C; --close-light: #A6ACCD; --close-background: #EFF2FB; width: 100%; max-width: 240px; display: flex; align-items: center; position: relative; border-radius: 8px; background: var(--background); box-shadow: inset 0 0 0 var(--border-width,1px) var(--border,var(--border-default)); transition: box-shadow 0.2s; --favicon-scale: 0; --icon-offset: 0px; --clear-x: 0px; --clear-swipe-left: 0px; --clear-swipe-x: 0; --clear-swipe: 0px; --clear-scale: 0; --clear-rotate: 0deg; --clear-opacity: 0; --clear-arrow-o: 1; --clear-arrow-x: 0px; --clear-arrow-y: 0px; --clear-arrow-offset: 4px; --clear-arrow-offset-second: 4px; --clear-line-array: 8.5px; --clear-line-offset: 27px; --clear-long-array: 8.5px; --clear-long-offset: 24px;}.url-input.clearing,.url-input:focus-within{--border-width: 1.5px; --border: var(--border-active);}.url-input.clearing{--close-background: transparent; --clear-arrow-stroke: var(--close-light);}.url-input .icon{position: absolute; left: 15px; top: 15px; pointer-events: none;}.url-input .icon svg,.url-input .icon img{display: block; width: 18px; height: 18px;}.url-input .icon svg{fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; stroke: var(--icon);}.url-input .icon svg path{stroke-dasharray: 24px; stroke-dashoffset: var(--icon-offset);}.url-input .icon .favicon{position: absolute; left: 0; top: 0; transform: scale(var(--favicon-scale)) translateZ(0);}.url-input .text{flex-grow: 1;}.url-input .text input{-webkit-appearance: none; line-height: 24px; background: none; border: none; outline: none; display: block; width: 100%; margin: 0; padding: 12px 12px 12px 44px; font-family: inherit; font-size: 14px; font-weight: 500; color: var(--text-color);}.url-input .text input::-moz-placeholder{color: var(--placeholder-color);}.url-input .text input:-ms-input-placeholder{color: var(--placeholder-color);}.url-input .text input::placeholder{color: var(--placeholder-color);}.url-input .clear{-webkit-appearance: none; position: relative; z-index: 1; padding: 0; margin: 12px 12px 12px 0; border: none; outline: none; background: var(--b,transparent); transition: background 0.2s; border-radius: 6px; opacity: var(--clear-opacity); transform: scale(var(--clear-scale)) translateZ(0);}.url-input .clear:before{content: ""; position: absolute; top: 0; bottom: 0; right: 12px; left: var(--clear-swipe-left); background: var(--background); transform-origin: 100% 50%; transform: translateX(var(--clear-swipe)) scaleX(var(--clear-swipe-x)) translateZ(0);}.url-input .clear svg{display: block; position: relative; z-index: 1; width: 24px; height: 24px; outline: none; cursor: pointer; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; stroke: var(--close); transform: translateX(var(--clear-x)) rotate(var(--clear-rotate)) translateZ(0);}.url-input .clear svg path{transition: stroke 0.2s;}.url-input .clear svg path.arrow{stroke: var(--clear-arrow-stroke,var(--close)); stroke-dasharray: 4px; stroke-dashoffset: var(--clear-arrow-offset); opacity: var(--clear-arrow-o); transform: translate(var(--clear-arrow-x),var(--clear-arrow-y)) translateZ(0);}.url-input .clear svg path.arrow:last-child{stroke-dashoffset: var(--clear-arrow-offset-second);}.url-input .clear svg path.line{stroke-dasharray: var(--clear-line-array) 28.5px; stroke-dashoffset: var(--clear-line-offset);}.url-input .clear svg path.long{stroke: var(--clear-arrow-stroke,var(--close)); stroke-dasharray: var(--clear-long-array) 15.5px; stroke-dashoffset: var(--clear-long-offset); opacity: var(--clear-arrow-o); transform: translate(var(--clear-arrow-x),var(--clear-arrow-y)) translateZ(0);}.url-input .clear:hover{--b: var(--close-background);}
</style>
</head>

<body>
<!-- Modified from https://codepen.io/aaroniker/pen/WNxoovJ -->
<div id="wrapper">
    <a href="javascript:;" id="cloner">Make copy</a>
    <div class="url-input">
        <div class="icon">
            <svg viewBox="0 0 18 18">
                <path d="M10.05 7.95001C11.55 9.45001 11.55 11.775 10.05 13.275L7.95 15.375C6.45 16.875 4.125 16.875 2.625 15.375C1.125 13.875 1.125 11.55 2.625 10.05L4.5 8.25001" />
                <path d="M7.9502 10.05C6.4502 8.55 6.4502 6.225 7.9502 4.725L10.0502 2.625C11.5502 1.125 13.8752 1.125 15.3752 2.625C16.8752 4.125 16.8752 6.45 15.3752 7.95L13.5002 9.75" />
            </svg>
            <div class="favicon"></div>
        </div>
        <div class="text">
            <input type="text" placeholder="Your URL" />
        </div>
        <button class="clear">
            <svg viewBox="0 0 24 24">
                <path class="line" d="M2 2L22 22" />
                <path class="long" d="M9 15L20 4" />
                <path class="arrow" d="M13 11V7" />
                <path class="arrow" d="M17 11H13" />
            </svg>
        </button>
    </div>
</div>

<template id="url-template" style="display:none;">
    <div class="url-input"> <div class="icon"> <svg viewBox="0 0 18 18"> <path d="M10.05 7.95001C11.55 9.45001 11.55 11.775 10.05 13.275L7.95 15.375C6.45 16.875 4.125 16.875 2.625 15.375C1.125 13.875 1.125 11.55 2.625 10.05L4.5 8.25001"/> <path d="M7.9502 10.05C6.4502 8.55 6.4502 6.225 7.9502 4.725L10.0502 2.625C11.5502 1.125 13.8752 1.125 15.3752 2.625C16.8752 4.125 16.8752 6.45 15.3752 7.95L13.5002 9.75"/> </svg> <div class="favicon"></div></div><div class="text"> <input type="text" placeholder="Your URL"/> </div><button class="clear"> <svg viewBox="0 0 24 24"> <path class="line" d="M2 2L22 22"/> <path class="long" d="M9 15L20 4"/> <path class="arrow" d="M13 11V7"/> <path class="arrow" d="M17 11H13"/> </svg> </button> </div>
</template>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.5/gsap.min.js"></script>

<script>
// From https://codepen.io/aaroniker/pen/WNxoovJ
const { to,set,timeline } = gsap

function validURL(str) {
    let pattern = new RegExp('^(https?:\\/\\/)?'+
        '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+
        '((\\d{1,3}\\.){3}\\d{1,3}))'+
        '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+
        '(\\?[;&a-z\\d%_.~+=-]*)?'+
        '(\\#[-a-z\\d_]*)?$','i')
    return !!pattern.test(str)
}

function delay(fn,ms) {
    let timer = 0
    return function(...args) {
        clearTimeout(timer)
        timer = setTimeout(fn.bind(this,...args),ms || 0)
    }
}

document.querySelectorAll('.url-input').forEach(elem => {
    let icon = elem.querySelector('.icon'),favicon = icon.querySelector('.favicon'),clear = elem.querySelector('.clear'),input = elem.querySelector('input'),{ classList } = elem,svgLine = clear.querySelector('.line'),svgLineProxy = new Proxy({
            x: null
        },{
            set(target,key,value) {
                target[key] = value
                if(target.x !== null) {
                    svgLine.setAttribute('d',getPath(target.x,.1925))
                }
                return true
            },get(target,key) {
                return target[key]
            }
        })

    svgLineProxy.x = 0

    input.addEventListener('input',delay(e => {
        let bool = input.value.length,valid = validURL(input.value)
        to(elem,{
            '--clear-scale': bool ? 1 : 0,duration: bool ? .5 : .15,ease: bool ? 'elastic.out(1,.7)' : 'none'
        })
        to(elem,{
            '--clear-opacity': bool ? 1 : 0,duration: .15
        })
        to(elem,{
            '--icon-offset': valid ? '24px' : '0px',duration: .15,delay: valid ? 0 : .2
        })
        if(valid) {
            if(favicon.querySelector('img')) {
                favicon.querySelector('img').src = 'https://f1.allesedv.com/64/' + input.value
                return
            }
            let img = new Image()
            img.onload = () => {
                favicon.appendChild(img)
                to(elem,{
                    '--favicon-scale': 1,duration: .5,delay: .2,ease: 'elastic.out(1,.7)'
                })
            }
            img.src = 'https://f1.allesedv.com/64/' + input.value
        } else {
            if(favicon.querySelector('img')) {
                to(elem,{
                    '--favicon-scale': 0,onComplete() {
                        favicon.querySelector('img').remove()
                    }
                })
            }
        }
    },250))

    clear.addEventListener('click',e => {
        classList.add('clearing')
        set(elem,{
            '--clear-swipe-left': (input.offsetWidth - 44) * -1 + 'px'
        })
        to(elem,{
            keyframes: [{
                '--clear-rotate': '45deg',duration: .25
            },{
                '--clear-arrow-x': '2px','--clear-arrow-y': '-2px',duration: .15
            },{
                '--clear-arrow-x': '-3px','--clear-arrow-y': '3px','--clear-swipe': '-3px',onStart() {
                    to(svgLineProxy,{
                        x: 3,duration: .1,delay: .05
                    })
                }
            },{
                '--clear-swipe-x': 1,'--clear-x': (input.offsetWidth - 32) * -1 + 'px',duration: .45,onComplete() {
                    input.value = ''
                    input.focus()
                    if(favicon.querySelector('img')) {
                        to(elem,{
                            '--favicon-scale': 0,onComplete() {
                                favicon.querySelector('img').remove()
                            }
                        })
                        to(elem,{
                            '--icon-offset': '0px','--icon-offset-line': '0px',delay: .2
                        })
                    }
                    to(elem,{
                        '--clear-arrow-offset': '4px','--clear-arrow-offset-second': '4px','--clear-line-array': '8.5px','--clear-line-offset': '27px','--clear-long-offset': '24px','--clear-rotate': '0deg','--clear-arrow-o': 1,duration: 0,delay: .7,onStart() {
                            classList.remove('clearing')
                        }
                    })
                    to(elem,{
                        '--clear-opacity': 0,duration: .2,delay: .55
                    })
                    to(elem,{
                        '--clear-arrow-o': 0,'--clear-arrow-x': '0px','--clear-arrow-y': '0px','--clear-swipe': '0px',duration: .15
                    })
                    to(svgLineProxy,{
                        x: 0,.75)'
                    })
                }
            },{
                '--clear-swipe-x': 0,'--clear-x': '0px',duration: .4,delay: .35
            }]
        })
        to(elem,{
            '--clear-arrow-offset': '0px','--clear-arrow-offset-second': '8px','--clear-line-array': '28.5px','--clear-line-offset': '57px','--clear-long-offset': '17px',duration: .2
        })
    })
})

function getPoint(point,i,a,smoothing) {
    let cp = (current,previous,next,reverse) => {
            let p = previous || current,n = next || current,o = {
                    length: Math.sqrt(Math.pow(n[0] - p[0],2) + Math.pow(n[1] - p[1],2)),angle: Math.atan2(n[1] - p[1],n[0] - p[0])
                },angle = o.angle + (reverse ? Math.PI : 0),length = o.length * smoothing;
            return [current[0] + Math.cos(angle) * length,current[1] + Math.sin(angle) * length];
        },cps = cp(a[i - 1],a[i - 2],point,false),cpe = cp(point,a[i - 1],a[i + 1],true);
    return `C ${cps[0]},${cps[1]} ${cpe[0]},${cpe[1]} ${point[0]},${point[1]}`;
}

function getPath(x,smoothing) {
    return [
        [2,2],[12 - x,12 + x],[22,22]
    ].reduce((acc,a) => i === 0 ? `M ${point[0]},${point[1]}` : `${acc} ${getPoint(point,smoothing)}`,'')
}
</script>

<script>
// jQuery 3.5.1 has already been included
$('#cloner').click(function(e){
    e.preventDefault();
    let $urlTemplate = $("template#url-template").html();
    let urlCopy = $($urlTemplate).clone();
    $("#wrapper").append(urlCopy);
    $(this).blur();
})
</script>
</body>
</html>

解决方法

document.querySelectorAll 只在脚本启动时调用一次,因此每次创建新输入时都必须再次执行。

为了避免重写你的代码, 你只是将 querySelectorAll 的初始化封装在一个函数中

function initInput() {
  document.querySelectorAll(".url-input").forEach((elem) => {
  :
  :
        to(elem,{
          "--clear-arrow-offset": "0px","--clear-arrow-offset-second": "8px","--clear-line-array": "28.5px","--clear-line-offset": "57px","--clear-long-offset": "17px",duration: 0.2,});
      });//end clear.addEventListener
    });//end queryselectorAll
}

你在脚本的开头和克隆器中调用它:

jQuery(function () {

  const { to,set,timeline } = gsap;
  initInput();
  $("#cloner").click(function (e) {
    e.preventDefault();
    let $urlTemplate = $("template#url-template").html();
    let urlCopy = $($urlTemplate).clone();
    $("#wrapper").append(urlCopy);
    $(this).blur();
    initInput();
  });
  :
  :

const { to,timeline } = gsap;
  initInput();
  $("#cloner").click(function (e) {
    e.preventDefault();
    let $urlTemplate = $("template#url-template").html();
    let urlCopy = $($urlTemplate).clone();
    $("#wrapper").append(urlCopy);
    $(this).blur();
    initInput();
  });

  function validURL(str) {
    let pattern = new RegExp(
      "^(https?:\\/\\/)?" +
        "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" +
        "((\\d{1,3}\\.){3}\\d{1,3}))" +
        "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" +
        "(\\?[;&a-z\\d%_.~+=-]*)?" +
        "(\\#[-a-z\\d_]*)?$","i"
    );
    return !!pattern.test(str);
  }

  function delay(fn,ms) {
    let timer = 0;
    return function (...args) {
      clearTimeout(timer);
      timer = setTimeout(fn.bind(this,...args),ms || 0);
    };
  }

  function initInput() {
    document.querySelectorAll(".url-input").forEach((elem) => {

      let icon = elem.querySelector(".icon"),favicon = icon.querySelector(".favicon"),clear = elem.querySelector(".clear"),input = elem.querySelector("input"),{ classList } = elem,svgLine = clear.querySelector(".line"),svgLineProxy = new Proxy(
          {
            x: null,},{
            set(target,key,value) {
              target[key] = value;
              if (target.x !== null) {
                svgLine.setAttribute("d",getPath(target.x,0.1925));
              }
              return true;
            },get(target,key) {
              return target[key];
            },}
        );

      svgLineProxy.x = 0;

      input.addEventListener(
        "input",delay((e) => {
          let bool = input.value.length,valid = validURL(input.value);
          to(elem,{
            "--clear-scale": bool ? 1 : 0,duration: bool ? 0.5 : 0.15,ease: bool ? "elastic.out(1,.7)" : "none",});
          to(elem,{
            "--clear-opacity": bool ? 1 : 0,duration: 0.15,{
            "--icon-offset": valid ? "24px" : "0px",delay: valid ? 0 : 0.2,});
          if (valid) {
            if (favicon.querySelector("img")) {
              favicon.querySelector("img").src =
                "https://f1.allesedv.com/64/" + input.value;
              return;
            }
            let img = new Image();
            img.onload = () => {
              favicon.appendChild(img);
              to(elem,{
                "--favicon-scale": 1,duration: 0.5,delay: 0.2,ease: "elastic.out(1,.7)",});
            };
            img.src = "https://f1.allesedv.com/64/" + input.value;
          } else {
            if (favicon.querySelector("img")) {
              to(elem,{
                "--favicon-scale": 0,onComplete() {
                  favicon.querySelector("img").remove();
                },});
            }
          }
        },250)
      );

      clear.addEventListener("click",(e) => {
        classList.add("clearing");
        set(elem,{
          "--clear-swipe-left": (input.offsetWidth - 44) * -1 + "px",});
        to(elem,{
          keyframes: [
            {
              "--clear-rotate": "45deg",duration: 0.25,{
              "--clear-arrow-x": "2px","--clear-arrow-y": "-2px",{
              "--clear-arrow-x": "-3px","--clear-arrow-y": "3px","--clear-swipe": "-3px",onStart() {
                to(svgLineProxy,{
                  x: 3,duration: 0.1,delay: 0.05,});
              },{
              "--clear-swipe-x": 1,"--clear-x": (input.offsetWidth - 32) * -1 + "px",duration: 0.45,onComplete() {
                input.value = "";
                input.focus();
                if (favicon.querySelector("img")) {
                  to(elem,{
                    "--favicon-scale": 0,onComplete() {
                      favicon.querySelector("img").remove();
                    },});
                  to(elem,{
                    "--icon-offset": "0px","--icon-offset-line": "0px",});
                }
                to(elem,{
                  "--clear-arrow-offset": "4px","--clear-arrow-offset-second": "4px","--clear-line-array": "8.5px","--clear-line-offset": "27px","--clear-long-offset": "24px","--clear-rotate": "0deg","--clear-arrow-o": 1,duration: 0,delay: 0.7,onStart() {
                    classList.remove("clearing");
                  },});
                to(elem,{
                  "--clear-opacity": 0,delay: 0.55,{
                  "--clear-arrow-o": 0,"--clear-arrow-x": "0px","--clear-arrow-y": "0px","--clear-swipe": "0px",});
                to(svgLineProxy,{
                  x: 0,.75)",{
              "--clear-swipe-x": 0,"--clear-x": "0px",duration: 0.4,delay: 0.35,],});
      });
    });
  }

  function getPoint(point,i,a,smoothing) {
    let cp = (current,previous,next,reverse) => {
        let p = previous || current,n = next || current,o = {
            length: Math.sqrt(
              Math.pow(n[0] - p[0],2) + Math.pow(n[1] - p[1],2)
            ),angle: Math.atan2(n[1] - p[1],n[0] - p[0]),angle = o.angle + (reverse ? Math.PI : 0),length = o.length * smoothing;
        return [
          current[0] + Math.cos(angle) * length,current[1] + Math.sin(angle) * length,];
      },cps = cp(a[i - 1],a[i - 2],point,false),cpe = cp(point,a[i - 1],a[i + 1],true);
    return `C ${cps[0]},${cps[1]} ${cpe[0]},${cpe[1]} ${point[0]},${point[1]}`;
  }

  function getPath(x,smoothing) {
    return [
      [2,2],[12 - x,12 + x],[22,22],].reduce(
      (acc,a) =>
        i === 0
          ? `M ${point[0]},${point[1]}`
          : `${acc} ${getPoint(point,smoothing)}`,""
    );
  }
.url-input {
    --background: #fff;
    --border-default: #E1E6F9;
    --border-active: #275EFE;
    --text-color: #646B8C;
    --placeholder-color: #BBC1E1;
    --icon: #275EFE;
    --close: #646B8C;
    --close-light: #A6ACCD;
    --close-background: #EFF2FB;
    width: 100%;
    max-width: 240px;
    display: flex;
    align-items: center;
    position: relative;
    border-radius: 8px;
    background: var(--background);
    box-shadow: inset 0 0 0 var(--border-width,1px) var(--border,var(--border-default));
    transition: box-shadow 0.2s;
    --favicon-scale: 0;
    --icon-offset: 0px;
    --clear-x: 0px;
    --clear-swipe-left: 0px;
    --clear-swipe-x: 0;
    --clear-swipe: 0px;
    --clear-scale: 0;
    --clear-rotate: 0deg;
    --clear-opacity: 0;
    --clear-arrow-o: 1;
    --clear-arrow-x: 0px;
    --clear-arrow-y: 0px;
    --clear-arrow-offset: 4px;
    --clear-arrow-offset-second: 4px;
    --clear-line-array: 8.5px;
    --clear-line-offset: 27px;
    --clear-long-array: 8.5px;
    --clear-long-offset: 24px;
  }
  
  .url-input.clearing,.url-input:focus-within {
    --border-width: 1.5px;
    --border: var(--border-active);
  }
  
  .url-input.clearing {
    --close-background: transparent;
    --clear-arrow-stroke: var(--close-light);
  }
  
  .url-input .icon {
    position: absolute;
    left: 15px;
    top: 15px;
    pointer-events: none;
  }
  
  .url-input .icon svg,.url-input .icon img {
    display: block;
    width: 18px;
    height: 18px;
  }
  
  .url-input .icon svg {
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke: var(--icon);
  }
  
  .url-input .icon svg path {
    stroke-dasharray: 24px;
    stroke-dashoffset: var(--icon-offset);
  }
  
  .url-input .icon .favicon {
    position: absolute;
    left: 0;
    top: 0;
    transform: scale(var(--favicon-scale)) translateZ(0);
  }
  
  .url-input .text {
    flex-grow: 1;
  }
  
  .url-input .text input {
    -webkit-appearance: none;
    line-height: 24px;
    background: none;
    border: none;
    outline: none;
    display: block;
    width: 100%;
    margin: 0;
    padding: 12px 12px 12px 44px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
  }
  
  .url-input .text input::-moz-placeholder {
    color: var(--placeholder-color);
  }
  
  .url-input .text input:-ms-input-placeholder {
    color: var(--placeholder-color);
  }
  
  .url-input .text input::placeholder {
    color: var(--placeholder-color);
  }
  
  .url-input .clear {
    -webkit-appearance: none;
    position: relative;
    z-index: 1;
    padding: 0;
    margin: 12px 12px 12px 0;
    border: none;
    outline: none;
    background: var(--b,transparent);
    transition: background 0.2s;
    border-radius: 6px;
    opacity: var(--clear-opacity);
    transform: scale(var(--clear-scale)) translateZ(0);
  }
  
  .url-input .clear:before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 12px;
    left: var(--clear-swipe-left);
    background: var(--background);
    transform-origin: 100% 50%;
    transform: translateX(var(--clear-swipe)) scaleX(var(--clear-swipe-x)) translateZ(0);
  }
  
  .url-input .clear svg {
    display: block;
    position: relative;
    z-index: 1;
    width: 24px;
    height: 24px;
    outline: none;
    cursor: pointer;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke: var(--close);
    transform: translateX(var(--clear-x)) rotate(var(--clear-rotate)) translateZ(0);
  }
  
  .url-input .clear svg path {
    transition: stroke 0.2s;
  }
  
  .url-input .clear svg path.arrow {
    stroke: var(--clear-arrow-stroke,var(--close));
    stroke-dasharray: 4px;
    stroke-dashoffset: var(--clear-arrow-offset);
    opacity: var(--clear-arrow-o);
    transform: translate(var(--clear-arrow-x),var(--clear-arrow-y)) translateZ(0);
  }
  
  .url-input .clear svg path.arrow:last-child {
    stroke-dashoffset: var(--clear-arrow-offset-second);
  }
  
  .url-input .clear svg path.line {
    stroke-dasharray: var(--clear-line-array) 28.5px;
    stroke-dashoffset: var(--clear-line-offset);
  }
  
  .url-input .clear svg path.long {
    stroke: var(--clear-arrow-stroke,var(--close));
    stroke-dasharray: var(--clear-long-array) 15.5px;
    stroke-dashoffset: var(--clear-long-offset);
    opacity: var(--clear-arrow-o);
    transform: translate(var(--clear-arrow-x),var(--clear-arrow-y)) translateZ(0);
  }
  
  .url-input .clear:hover {
    --b: var(--close-background);
  }
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.0.5/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="wrapper">
            <a href="javascript:;" id="cloner">Make copy</a>
            <div class="url-input">
                <div class="icon">
                    <svg viewBox="0 0 18 18">
                        <path d="M10.05 7.95001C11.55 9.45001 11.55 11.775 10.05 13.275L7.95 15.375C6.45 16.875 4.125 16.875 2.625 15.375C1.125 13.875 1.125 11.55 2.625 10.05L4.5 8.25001" />
                        <path d="M7.9502 10.05C6.4502 8.55 6.4502 6.225 7.9502 4.725L10.0502 2.625C11.5502 1.125 13.8752 1.125 15.3752 2.625C16.8752 4.125 16.8752 6.45 15.3752 7.95L13.5002 9.75" />
                    </svg>
                    <div class="favicon"></div>
                </div>
                <div class="text">
                    <input type="text" placeholder="Your URL" />
                </div>
                <button class="clear">
                    <svg viewBox="0 0 24 24">
                        <path class="line" d="M2 2L22 22" />
                        <path class="long" d="M9 15L20 4" />
                        <path class="arrow" d="M13 11V7" />
                        <path class="arrow" d="M17 11H13" />
                    </svg>
                </button>
            </div>
        </div>
        
        <!-- <template id="url-template" style="display:none;"> -->
        <template id="url-template" style="display:none;">
            <div class="url-input"> <div class="icon"> <svg viewBox="0 0 18 18"> <path d="M10.05 7.95001C11.55 9.45001 11.55 11.775 10.05 13.275L7.95 15.375C6.45 16.875 4.125 16.875 2.625 15.375C1.125 13.875 1.125 11.55 2.625 10.05L4.5 8.25001"/> <path d="M7.9502 10.05C6.4502 8.55 6.4502 6.225 7.9502 4.725L10.0502 2.625C11.5502 1.125 13.8752 1.125 15.3752 2.625C16.8752 4.125 16.8752 6.45 15.3752 7.95L13.5002 9.75"/> </svg> <div class="favicon"></div></div><div class="text"> <input type="text" placeholder="Your URL"/> </div><button class="clear"> <svg viewBox="0 0 24 24"> <path class="line" d="M2 2L22 22"/> <path class="long" d="M9 15L20 4"/> <path class="arrow" d="M13 11V7"/> <path class="arrow" d="M17 11H13"/> </svg> </button> </div>
        </template>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res