Mntad
Content Type
Profiles
Forums
Store
Blog
Product
Showcase
FAQ
Downloads
Posts posted by Mntad
-
-
26 minutes ago, Jonathan said:
Hello @Mntad and welcome to the GreenSock Forum!
Usually that error happens because your GSAP getRule() code is running before your CSS your trying to reference in your GSAP code CSSRulePlugin.getRule(). So if your JS is trying to getRule() that hasnt been loaded in to memory then you will get that error about accessing the CSS Rules.
I notice you have a DOM ready your checking before running your code. You might want to put a window load event inside your DOM ready event. The reason being is that DOM ready doesnt check for external CSS files being loaded. That check happens with the window load event which makes sure all external aseets like images, links, fonts, CSS stylesheets, and JS scripts are loaded.
Try this since your using jQuery to make sure your code doesn't run until all assets a have been loaded:
// wait until the DOM is fully loaded (html, svg, markup etc) $(document).ready(function() { // wait until all external assets are loaded (css stylesheets, js scripts, fonts, images, etc) $(window).bind("load", function() { // custom GSAP code goes here }); });
Happy Tweening!
Hi @Jonathan thank's for the reply i tried what you've suggested well the code got executed after everything loads but i'm still getting the same error of undefined
-
6 hours ago, GreenSock said:
Welcome to the forums, @Mntad. It's tough to diagnose a live site like that, but I'd make two suggestions:
- Make sure you're using the latest GreenSock files. It looks like you're using a file that's REALLY old (2014).
- Try creating a reduced test case that demonstrates the issue, hopefully in something like codepen so that we can tinker around and see exactly what's going on.
You are writing the rules exactly as you have them in the CSS, right?
Also, you might want to check this out: https://stackoverflow.com/questions/48753691/cannot-access-cssrules-from-local-css-file-in-chrome-64/49160760#49160760
Hi again this is exactly what i'm using in my live website with the same jquery and gsap cdn with the latest versions everything seems to work fine in codepen but in my website it returns TweenMax.min.js:17 Uncaught Cannot tween a null target. the problem i triggers when i click on the hamburger i console log the output of selected classes with CssPlugin and i've got 'undefined' you can check it from https://www.mntad.com/
See the Pen aRaRxQ by brahimchougrani (@brahimchougrani) on CodePen
-
hello so i tried using CSSRulePlugin.js it worked fine in local i'm using django default local server but when i load it in the production server it doesn't work at all i tried using gsap cdn my cdn from amazon loading if from the same domain but nothing seems to work the console prints me
Quote'DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules
at Function.CSSRulePlugin.getRule (https://www.mntad.com/static/js/CSSRulePlugin.js:60:19)'my code is :
Quotevar rule3 = CSSRulePlugin.getRule(".hamburger-inner");
var rule1 = CSSRulePlugin.getRule(".hamburger--collapse.is-active .hamburger-inner:after");
var rule2 = CSSRulePlugin.getRule(".hamburger--collapse.is-active .hamburger-inner:before");
var rule4 = CSSRulePlugin.getRule(".navbg");
here is the website the animation trigger when you click on the hamburger
CSSRulePlugin Not working
in GSAP
Posted
@Jonathan Thanks again i really appreciate your help the problem is the tweens are working fine in development environment but not on the live server i fixed all the problems related to content security policy but still having error i'm hosting my fiels in aws s3 and these are my cors settings my fiels are public and i have access to them i'm having a trouble figuring it out