|
经过和kuing讨论并参考StackOverflow以后, 发现修改transform后width和height不变,导致parent并不会跟着resize.
As described in the spec:
In the HTML namespace, the transform property does not affect the flow of the content surrounding the transformed element.
后来就放弃transform, 直接修改width和height如下
- function bbimg(e){
- if(!e.shiftKey) return;
- let scale = e.deltaY>0 ? 1.1 : 0.9,
- temp_w=parseFloat(this.getBoundingClientRect().width),
- temp_h=parseFloat(this.getBoundingClientRect().height);
- this.classList.remove('mw100');
- this.setAttribute("width", temp_w*scale);
- this.setAttribute("height", temp_h*scale);
- }
- function togglemw100(){
- this.removeAttribute('width');
- this.removeAttribute('height');
- this.classList.toggle('mw100');
- }
- var images=document.querySelectorAll('.t_fsz img:not([onclick^=show_tikz_window])');
- for (let item of images) {
- togglemw100.call(item);
- item.removeAttribute("onclick");
- item.addEventListener("click", togglemw100);
- item.addEventListener("wheel", bbimg);
- }
复制代码 |
|