Giter VIP home page Giter VIP logo

delegateify's Issues

目前的使用方式还是稍显麻烦

todo

在jQuery中可以这样使用

$(document).on('click scroll',function(){

})

$('.selector').on('click',function(){

})

可以看到jQuery的用法

  1. 不需要new,那么麻烦了
  2. 可以同时绑定多个事件,只需要使用空格分隔

在delegateify中也可以实现类似的用法

delegateify(document).on('click scroll',function(){

})

delegateify('.selector').on('click',function(){

})

目前的使用方式,也不是不能用,等有空了,再支持吧,记录一下,免得忘记了

Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Home</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
</head>

<body>
    <script src="https://unpkg.com/delegateify@latest/dist/delegateify.min.js"></script>

    <div class="box">
        <div>dsada</div>
        <button>btn</button>
    </div>

    <script>


        new Delegateify('.box').on(
            'touchstart',
            `button`,
            function (event) {
                console.log('touchstart');
            }
        )

        // document.querySelector('button').addEventListener('touchstart', function (event) {
        //     console.log('touchstart22');
        // }, {
        //     passive: true
        // })

    </script>
</body>

</html>

复现

解决办法就是添加passive: true,希望支持这个参数,这样就可以解决这个在控制台的警告问题

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.