-
Notifications
You must be signed in to change notification settings - Fork 174
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
Element not found or incorrect selector: path #29
Comments
ok I try to setup it on codepen -> The error is present but the simple morph exmple of the doc seem to work properly. In my case I can't make this demo work. In this project I work with angular 2, from my component I'm able to access to KUTE but when I try to start an animation nothing happens.
this.tween return me an object who seems correct. I'll try to setup a plunker with my settings. |
Here's a plunker with the issue |
Gimme a minute to investigate. |
Try to move your tween The natural order of scripting:
The point of this is:
|
Thanks for the reply. But as you can see in the plunker I work with Angular2 (who handle dependency injection). I need to manipulate svg (use of KUTE) from my component.
Everything seems ok but nothing happen in my view. So it's not a scripting order issue. |
My experience with Angular is ZERO, but still I want to know more. Show me the code where you define the tween object. (In the plunket example) |
https://plnkr.co/edit/S98TV49MJmlGKZlvKK7H?p=preview //our root app component
import {Component, NgModule} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
declare var KUTE;
@Component({
selector: 'my-app',
template: `
<div>
<h2>Hello {{name}}</h2>
<button (click)="test()">MORPH</button>
<svg id="morph-example" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<path id="rectangle" class="bg-lime" d="M38.01,5.653h526.531c17.905,0,32.422,14.516,32.422,32.422v526.531 c0,17.905-14.517,32.422-32.422,32.422H38.01c-17.906,0-32.422-14.517-32.422-32.422V38.075C5.588,20.169,20.104,5.653,38.01,5.653z"/>
<path id="star" style="visibility:hidden" d="M301.113,12.011l99.25,179.996l201.864,38.778L461.706,380.808 l25.508,203.958l-186.101-87.287L115.01,584.766l25.507-203.958L0,230.785l201.86-38.778L301.113,12.011"/>
</svg>
</div>
`,
})
export class App {
constructor() {
this.name = 'Angular2 (Release Candidate!)'
}
test() {
**var tween = KUTE.fromTo('#rectangle', {path: '#rectangle' }, { path: '#star' }).start();**
console.log(tween);
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {} |
You can see in the template (In the "@component") my |
OK. The angular stuff tries to do it's work on document render as I understand, KUTE.js will animate anything that's already existing in the DOM, so try to wrap the click action in |
It's an angular 1.x way to do this in angular 2.x you have to use specific method (described here https://angular.io/docs/ts/latest/guide/lifecycle-hooks.html, implements onInit or ngAfterContentInit or others). I have updated the plunker this way. But still no animation. |
The error is not there but animation does not occur because the |
Please try to change the angular scripting to make it work with this HTML <!DOCTYPE html>
<html>
<head>
<base href="." />
<title>angular2 playground</title>
<link rel="stylesheet" href="style.css" />
<script src="https://npmcdn.com/zone.js@0.6.12/dist/zone.js"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3/Reflect.js"></script>
<script src="https://npmcdn.com/systemjs@0.19.31/dist/system.js"></script>
<script src="https://npmcdn.com/typescript@1.8.10/lib/typescript.js"></script>
<script src="config.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/kute.js/1.5.1/kute.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/kute.js/1.5.1/kute-svg.min.js"></script>
<script>
var tween = KUTE.fromTo('#rectangle', {path: '#rectangle' }, { path: '#star' });
test() {
!tween.playing && tween.start();
console.log(tween);
}
</script>
</html> |
If I try this way -> "Element not found or incorrect selector: #rectangle" And it's normal in angular, I have to do all manipulation from the component class. When index.html is loaded (and the script with it) my view isn't rendered (no svg). |
IMO you should get rid of this angular stuff, the My final note before I close this: please try to order the code execution in a way that we have the HTML5 scripting done properly:
Since I don't use and perhaps never will use Angular, it's up to you to look it up, and please let me know what you can find. |
OK ! I didn't understand that, when KUTE (the core) initialize my svg needs to be already in the DOM (_sv and _se init at this time for each path in my DOM ?). For testing purpose it's ok without angular but my current project use angular so I've to make it work with it. I'll try this and let you know. |
Yes, KUTE.js expects elements to be in the DOM so it can find it and build the tween object with proper UPDATE: I've posted a SO question, maybe some more advanced users can help out. |
Some user suggested you should use an empty SVG in your HTML so that my script can work. |
I think I know why the script fails in the end, it's because the SVG Plugin is looking for a SVG element to check it's namespace and since there is none, please download latest version of the |
Hi,
I try to test this library for svg manipulations. After library and plugin loaded ->
I have this error in my console "Element not found or incorrect selector: path", this error happen only when the svg plugin is loaded.
Thanks for the help.
The text was updated successfully, but these errors were encountered: