Code Monkey home page Code Monkey logo

hello-houdini's Issues

module script evaluate two times

hi, I try the last demo Animated Polka Dot Fade, and I notice that worklet.js is evaluated two times.

I just add some console in the demo code:

CSS.registerProperty({
    name: '--dot-color',
    syntax: '<color>',
    initialValue: '#fff'
});
console.log('hello 1');
CSS.paintWorklet.addModule('worklet.js');
console.log('hello 2');

worklet.js is:

console.log('worklet.js');
var num = 0;
class PolkaDotFadePainter {
    static get inputProperties() {
        return ['--dot-spacing', '--dot-fade-offset', '--dot-color'];
    }

    paint(ctx, size, props) {
        num ++;
        console.log(123, num);
        let spacing = props.get('--dot-spacing').value;
        let fadeOffset = props.get('--dot-fade-offset').value;
        let color = props.get('--dot-color').toString();

        ctx.fillStyle = color;
        for (let y = 0; y < size.height + spacing; y += spacing) {
            ....//not change
        }
    }
}

registerPaint('polka-dot-fade', PolkaDotFadePainter);

The output is.

hello 1
hello 2
worklet.js
worklet.js
123 1
123 1
123 2
123 3
123 4
123 2
123 3
123 5

Obviously paint callback is bind two times.

And in Performance, evaluate module appears two times.
qq 20180410161418

My chrome is 65.0.3325.181 and I use localhost(http) to test it. Then I add console to the same demo in codepen, and console is executed once.
In Performance, evaluate module also appears two times, but it seem only executes once.
qq 20180410162634

I think the difference result is because of https, but I don't have a real https environment, so it's just a guess. Have you face the same problem? :)

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.