Comments (16)
The issue like that usually appears if you place the link to the lib inside the head
tag.
The library adds it's modules to the parent
option (this.o.parent
) you have specified on module construction, if you haven't specify anything in parent
option, it fallbacks to the body
:
((this.o.parent || document.body).appendChild
). Thus it tries to access body
that hasn't been yet initialised. If you move the script
inside body tag (or better to the end of the body
tag), it should solve the issue.
Hope it helps.
from mojs.
Hey @Jordan4jc! Thanks for the alert!
Cloud you please make the issue sample somewhere on codepen or similar? Not sure I got the problem right. The error seems for that you are passing an object but not HTMLNode
to parent
option. jQuery's .get(0)
will get HTMLNode
for you so it solves the issue.
Still not sure what do you want to achieve, a small code sample
will help a lot.
Thanks!
from mojs.
@Jordan4jc try using https://api.jquery.com/toArray/ to get an array of elements in your selection. I would suggest building a mixin or helper to call the animation code directly from the components as well.
from mojs.
Hi @kmiyashiro! Thanks for the solution. I still don't get the issue and would deeply appreciate if you could make a code sample with it? Thanks!
from mojs.
I have plans to try to make a code sample to see if I can get the same effect, I'll also give the toArray a shot as right now I'm hacking it to make it work. @kmiyashiro I plan on making it a mixin or a component once I find the best way to put it all together. Probably as soon as mo.js docs get a bit more full.
from mojs.
@Jordan4jc thanks!
from mojs.
I have this issue too, what i want to do, is select all elements with some classes and animate all of them, instead of using pure js like (using like this, work great, for one element):
I would like to use:
But when i use the code above i get the same error as @Jordan4jc mentioned
from mojs.
From that error, it seems like appendChild() is being called on some element. My guess is that it is getting a DOM element, so you should look into wrapping it like this:
$(this.o.parent || document.body).appendChild
to turn it into a jQuery object with that function available.
from mojs.
@legomushroom I have my scripts at the end of body tag and i have timeout as well. So, for me this isn't the solution. Thanks.
from mojs.
@BenevidesLecontes could you make an example on codepen?
from mojs.
@legomushroom take this plunker http://plnkr.co/edit/urqqKI?p=preview, click on resolveview link and test. You'll see icons animating, using pure js, uncomment the line using jquery and you'll see the error on the console. Thanks
from mojs.
@BenevidesLecontes thanks for the demo.
If you use var el11 = document.querySelectorAll('span.icobutton')[0]
- you take the first element in the search - [0]
. So when you use $
, take the first element too:
var el11 = angular.element($('span.icobutton')[0]), el11span = angular.element($('i.fa-microphone')[0]);
This way no errors fire. [http://plnkr.co/edit/g2xz2g6OuP7ZG4rjXJKK?p=preview]
As I got it, you want both icons to work the same way?
from mojs.
Yes I want to select all the items and animate them all the same way. With your edited line, the error keep showing in the console and the icons don't work.
from mojs.
@BenevidesLecontes updated the plunker http://plnkr.co/edit/g2xz2g6OuP7ZG4rjXJKK?p=preview
from mojs.
@BenevidesLecontes pushed more updates. Right now it creates the animation sequence for each icon with createAnimation
function. Note that the parent
option expects DOMNode
-- not jQuery
wrapped element nor NodeList
. The next mojs
release that I will make shortly will allow you to easily reuse the same sequence multiple times. Hope it helps.
from mojs.
@legomushroom Thanks for the help and thanks for this amazing library.
from mojs.
Related Issues (20)
- "Running Locally" guide HOT 1
- GPR publication workflow failure HOT 2
- Not working on IE HOT 2
- then() method is firing error "TypeError: Cannot read property '4' of null" HOT 9
- 可以为mojs添加一个removeShape的功能吗 HOT 3
- Improve the way custom shapes are instantiated HOT 4
- Unable to import in "modules" mode HOT 3
- The file imported by cdn reports an error(a native html page) HOT 2
- Como corrigir o erro/How to fix the error: Uncaught TypeError: Cannot read properties of null (reading 'appendChild') HOT 1
- Offset on click animations HOT 3
- Frame-by-frame animation HOT 6
- Independent delta not working in .then HOT 4
- Move Shape To Absolute Position HOT 1
- Document How to Add `pointer-events: none` To Shape/Timeline HOT 2
- @mojs/core not working with remix.run > ReferenceError: self is not defined HOT 1
- Mo.js support for typescript HOT 1
- Upgrade to NodeJS 20 HOT 5
- Showcase code is not working HOT 3
- The `dist` folder is missing in the npm package for `v1.7.0` HOT 1
- Tween has chance to be played 2 times rapidly in a timeline. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mojs.