These web details you have mastered it?

Remove event.preventDefault ()

  1. If an event is sometimes necessary to call event.preventDefault()to cancel the browser's default event, sometimes you need to call
  2. For example, a custom scroll bar when the scroll bar to scroll to the top of yet or the very bottom, you need to call event.preventDefault()to cancel the browser's default event, or a scroll bar will appear from the definition of scroll bars and scrolling while the outermost document
  3. When the scroll bar to scroll to the very top or the very bottom, custom scrollbars can not scroll up, you need to make the scroll bar to scroll the outermost layer of the document, it needs to be removedevent.preventDefault()
  • The current solution is to cancel the event binding, sample code:

    function F = var (E) { 
        // ... 
        // scroll minimum to maximum, rebind events, corresponding to remove the preventDefault 
        IF (that.current> = that.maxCurrent that.current || <= 0) { 
            that.wrapEl.off ( "MouseWheel DOMMouseScroll", F) .on ( "MouseWheel DOMMouseScroll", F); 
        } the else { 
            e.preventDefault (); 
        } 
    } 
    this.wrapEl.on ( "MouseWheel DOMMouseScroll", F); // add scroll events to dom
    

      

Guess you like

Origin www.cnblogs.com/yrfcxy/p/11325442.html
Recommended