Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typ image doesn't work #3

Open
mwinner-cc opened this issue Aug 14, 2017 · 5 comments
Open

Typ image doesn't work #3

mwinner-cc opened this issue Aug 14, 2017 · 5 comments

Comments

@mwinner-cc
Copy link

Thanks for the typeScript implementation but when I try to set an image for the type, I get an error:
ERROR TypeError: Cannot read property 'params' of undefined at loadImg (index.js:216) at ParticlesDirective.webpackJsonp.../../../../angular-particle/index.js.ParticlesDirective.ngAfterViewInit (index.js:1231) at callProviderLifecycles (core.es5.js:11182) at callElementProvidersLifecycles (core.es5.js:11157) at callLifecycleHooksChildrenFirst (core.es5.js:11141) at checkAndUpdateView (core.es5.js:12246) at callViewAction (core.es5.js:12603) at execComponentViewsAction (core.es5.js:12535) at checkAndUpdateView (core.es5.js:12244) at callViewAction (core.es5.js:12603)

myParams:
shape: { type: 'image', stroke: { width: 2, color: '#f0f8f5' }, image: { src: 'IMAGE PATH HERE' } },

@michaelfreund
Copy link

+1

@chriskyndrid
Copy link

chriskyndrid commented Dec 31, 2017

There are a few issues with how things are currently working:

in utils.ts loadImg()

let { particles } = this.params;
should be:
let { particles } = params;

additionally loadImg() makes an XHR request, ParticlesDirective calls loadImg() and doesn't wait for a response:

If you're trying to load an SVG Image, in ParticlesDirective.ngAfterViewInit():

if (isInArray('image', this._params.particles.shape.type)) {
	this._tmpParams.img_type = this._params.particles.shape.image.src.substr(this._params.particles.shape.image.src.length - 3);
	loadImg(this._params, this._tmpParams);
}

this._canvasManager = new CanvasManager(this._canvasParams, this._params, this._tmpParams);
this._canvasManager.draw();

the CanavasManager will execute the draw() method, prior to completion of the XHR request. Values, such as:

tmp.source_svg = data.currentTarget.response;

Will not exist when, in the constructor for Particle:

this._setupAnimation()

is called:

            if (this._tmpParams.img_type == 'svg' && this._tmpParams.source_svg != undefined) {
                createSvgImg(this, this._tmpParams);
                if (this._tmpParams.pushing) {
                    this.img.loaded = false;
                }
            }

Critical values for createSvgImg(store in this._tmpParams) will be missing.

        this._canvasManager = new CanvasManager(this._canvasParams, this._params, this._tmpParams);
        this._canvasManager.draw();

I think loadImg should be handled differently than it currently is. Ideally the XHR request is removed and updated to work more appropriately within Angular.

@AaronLavers
Copy link

Is there an update for this?

@nemolovich
Copy link
Contributor

Pull request: #16

@fucazu
Copy link

fucazu commented Nov 28, 2018

Is there an update? When PR will be accepted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants