Overflow hidden and input text scrolling in Google Chrome

后端 未结 4 1096
梦谈多话
梦谈多话 2021-01-19 13:07

Here is my code snippet:

http://jsfiddle.net/7CuBV/6/

If i click and drag over the input text field, I get the div with overflow:hidden scrolling as it would

4条回答
  •  终归单人心
    2021-01-19 13:54

    I ran into this, too. So far, the thing I've gotten to work the best is using pointer-events:none;. The only way I could get it to be applied was to set the display: none;. Otherwise it was ignored, so there's a brief blink.

    http://jsfiddle.net/7CuBV/21/

    var tx = document.getElementById('tx'),
        bod = document.body;
    
    tx.addEventListener('mousedown', tx_ondown);
    
    function tx_ondown() {
        bod.addEventListener('mousemove', b_onmove);
        bod.addEventListener('mouseup', b_onup);  
        bod.addEventListener('mouseout', b_onup);    
    }
    
    function b_onmove() {
        tx.style.pointerEvents = 'none';
        tx.style.display = 'none';
    
        setTimeout(function() {
            tx.style.display = '';
        }, 0);
        bod.removeEventListener('mousemove', b_onmove);
    }
    
    function b_onup() {
        if (tx.style.pointerEvents === 'none') {
            tx.style.pointerEvents = '';
        } else {
            bod.removeEventListener('mousemove', b_onmove);
        }
        bod.removeEventListener('mouseup', b_onup);
        bod.removeEventListener('mouseout', b_onup);        
    }​
    

提交回复
热议问题