zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    svg click event bug & css pointer-events

    svg click event not working

    Error

    OK ???

    css class

    
    
    /* disabled svg click event */
    /*
    svg {
      pointer-events: none;
    }
     */
    /* enabled svg click event */
    svg {
      pointer-events: all;
    }
    
    svg .selected-svg{
      stroke: #f00 !important;
      fill: #0f0 !important;
      stroke- 10 !important;
      stroke-linejoin: round;
      /* stroke-linejoin: bevel;
      stroke-linejoin: miter;
      stroke-linecap: round;
      stroke-linecap: butt;
      stroke-linecap: square; */
    }
    
    
    
    
    /* disabled svg click event */
    /*
    svg {
      pointer-events: none;
    }
     */
    /* enabled svg click event */
    svg {
      pointer-events: all;
    }
    
    
    

    https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events

    pointer-events

    
    /* Keyword values */
    pointer-events: auto;
    pointer-events: none;
    pointer-events: visiblePainted; /* SVG only */
    pointer-events: visibleFill;    /* SVG only */
    pointer-events: visibleStroke;  /* SVG only */
    pointer-events: visible;        /* SVG only */
    pointer-events: painted;        /* SVG only */
    pointer-events: fill;           /* SVG only */
    pointer-events: stroke;         /* SVG only */
    pointer-events: all;            /* SVG only */
    
    /* Global values */
    pointer-events: inherit;
    pointer-events: initial;
    pointer-events: unset;
    
    
    

    svg

    
      cancelSelected(className = `selected-svg`) {
        // this.reverseColor();
        // this.setStyle(true);
        this.rect.classList.remove(className);
      }
      clickSelected(className = `selected-svg`) {
        // this.reverseColor();
        // this.setStyle();
        this.rect.classList.add(className);
      }
      setStyle(clear = false) {
        let style = "";
        if(!clear) {
          style = "stroke: red; stroke- 5;";
        }
        this.rect.setAttribute("style", style);
      }
      reverseColor() {
        const originColor = this.rect.getAttribute("fill");
        const color = `#` + originColor.slice(1).split("").reverse().join("");
        this.rect.setAttribute("fill", color);
      }
    
    

    solution & dispatchEvent

    https://www.cnblogs.com/xgqfrms/p/12315162.html

              const dom = window.svgPolygon[uuid];
              // why ? svg element not support trigger click event!
              // dom.click();
              dom.dispatchEvent(new Event('click'));
    
    

    refs



    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    MySQL全面瓦解20:可编程性之流程控制语句
    MySQL全面瓦解19:游标相关
    MySQL全面瓦解18:自定义函数
    MySQL全面瓦解17:触发器相关
    MySQL全面瓦解16:存储过程相关
    MySQL全面瓦解15:视图
    MySQL全面瓦解14:事务
    MySQL全面瓦解13:系统函数相关
    MySQL全面瓦解12:连接查询的原理和应用
    MySQL全面瓦解11:子查询和组合查询
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/12310390.html
Copyright © 2011-2022 走看看